Re: extending ORDER BY make query much slower - Mailing list pgsql-sql

From Tom Lane
Subject Re: extending ORDER BY make query much slower
Date
Msg-id 29647.1047506458@sss.pgh.pa.us
Whole thread Raw
In response to extending ORDER BY make query much slower  ("Dan Langille" <dan@langille.org>)
Responses Re: extending ORDER BY make query much slower
List pgsql-sql
"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


pgsql-sql by date:

Previous
From: Tomasz Myrta
Date:
Subject: Re: "hide" values in a column
Next
From: Tom Lane
Date:
Subject: Re: View - Join based on dis-similar data types