Re: ORDER BY ... LIMIT.. performance - Mailing list pgsql-performance

From Tom Lane
Subject Re: ORDER BY ... LIMIT.. performance
Date
Msg-id 2707.1039125609@sss.pgh.pa.us
Whole thread Raw
In response to ORDER BY ... LIMIT.. performance  ("john cartmell" <john.cartmell@mediaburst.co.uk>)
List pgsql-performance
"john cartmell" <john.cartmell@mediaburst.co.uk> writes:
> Without the LIMIT clause the query takes approximately 3-5 seconds to
> return.
> If total number of rows returned without the LIMIT clause is greater
> than 20 records, then the above query also takes th same amount of time.
> But if the the total number of rows is 20 or less then the time taken
> for the above query to return goes up to 20-30 seconds.

What does EXPLAIN (or better EXPLAIN ANALYZE) show for these various
cases?  Evidently the planner is shifting to a different plan because
of the small LIMIT, but with no details it's hard to say anything
useful.

            regards, tom lane

pgsql-performance by date:

Previous
From: Vernon Wu
Date:
Subject: Re: Is a better way to have the same result of this query?
Next
From: Jochem van Dieten
Date:
Subject: Re: Is a better way to have the same result of this query?