Re: ORDER BY ... LIMIT.. performance

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "john cartmell" <john(dot)cartmell(at)mediaburst(dot)co(dot)uk>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: ORDER BY ... LIMIT.. performance
Date: 2002-12-05 22:00:09
Message-ID: 2707.1039125609@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

"john cartmell" <john(dot)cartmell(at)mediaburst(dot)co(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Jochem van Dieten 2002-12-05 22:05:57 Re: Is a better way to have the same result of this query?
Previous Message Vernon Wu 2002-12-05 21:23:16 Re: Is a better way to have the same result of this query?