From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dan Langille <dan@langille.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: extending ORDER BY make query much slower
Date: Wed, 12 Mar 2003 17:00:58 -0500
Message-ID: <29647.1047506458@sss.pgh.pa.us> (raw)
In-Reply-To: <3E6F45D8.15284.5994716@localhost>
References: <3E6F45D8.15284.5994716@localhost>
"Dan Langille" <dan@langille.org> writes:
> I've found that adding another field to the ORDER BY clause, times go
> through the roof.
Why does that surprise you? The original query is using an index to
achieve the required ordering, so it can give you the first 100 rows
without bothering to compute the remainder. The modified query has to
actually compute all the rows, and sort them, before it knows which are
the first 100.
If you had an index matching the second ORDER BY clause, you'd probably
get a plan similar to the first case.
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-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, dan@langille.org
Subject: Re: extending ORDER BY make query much slower
In-Reply-To: <29647.1047506458@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