From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pierre-Frédéric Caillaud <lists@boutiquenumerique.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: The usual sequential scan, but with LIMIT !
Date: Tue, 07 Sep 2004 09:47:47 -0400
Message-ID: <29692.1094564867@sss.pgh.pa.us> (raw)
In-Reply-To: <opsdx2os1ncq72hf@musicbox>
References: <4134BF36.3000504@syscor.com>
<413BA104.1040508@geizhals.at>
<b068057c040905181998476d1@mail.gmail.com>
<opsdwm0iujcq72hf@musicbox>
<14846.1094488841@sss.pgh.pa.us>
<opsdx2os1ncq72hf@musicbox>
=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= <lists@boutiquenumerique.com> writes:
> suppose I SELECT WHERE topic_id=2 ORDER BY topic_id ASC,id DESC.
> Postgres does a seq scan, but it could think a bit more and start at
> "first index node which has topic_id>2" (simple to find in a btree) then
> go backwards in the index.
If you write it as
SELECT WHERE topic_id=2 ORDER BY topic_id DESC,id DESC.
then an index on (topic_id, id) will work fine. The mixed ASC/DESC
ordering is not compatible with the index.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, lists@boutiquenumerique.com
Subject: Re: The usual sequential scan, but with LIMIT !
In-Reply-To: <29692.1094564867@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox