Skip site navigation (1) Skip section navigation (2)

Re: SQL select query becomes slow when using limit (with no offset)

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Kees van Dieren <keesvandieren(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: SQL select query becomes slow when using limit (with no offset)
Date: 2009-07-31 12:42:26
Message-ID: 407d949e0907310542k613d2beeqddf17424e22e7d43@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
On Fri, Jul 31, 2009 at 1:11 PM, Kees van Dieren<keesvandieren(at)gmail(dot)com> wrote:
> It takes 155ms to run this query (returning 2 rows)
>
> Query plan: without limit:
> "Sort  (cost=20169.62..20409.50 rows=95952 width=16)"

Could you send the results of EXPLAIN ANALYZE for both queries?
Evidently the planner is expecting a lot more rows than the 2 rows
you're expecting but it's not clear where it's gone wrong.


-- 
greg
http://mit.edu/~gsstark/resume.pdf

In response to

Responses

pgsql-performance by date

Next:From: PFCDate: 2009-07-31 12:46:45
Subject: Re: SQL select query becomes slow when using limit (with no offset)
Previous:From: Kees van DierenDate: 2009-07-31 12:11:14
Subject: SQL select query becomes slow when using limit (with no offset)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group