pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedAppending "LIMIT" to query drastically decreases performance
4+ messages / 3 participants
[nested] [flat]
* Appending "LIMIT" to query drastically decreases performance
@ 2007-11-30 11:16 cluster <skrald@amossen.dk>
0 siblings, 1 reply; 4+ messages in thread
From: cluster @ 2007-11-30 11:16 UTC (permalink / raw)
To: pgsql-performance
Can anyone explain the following odd behavior?
I have a query that completes in about 90 ms. If I append LIMIT to the
very end, eg. "LIMIT 500" the evaluation time increases to about 800 ms.
How can performance get *worse* by giving the database the option to
stop the evaluation earlier (when it reaches the output 500 rows)?
I have pasted both queries together with output from explain analyze here:
http://pastebin.com/m3c0d1896
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Appending "LIMIT" to query drastically decreases performance
@ 2007-11-30 13:30 Matthew <matthew@flymine.org>
parent: cluster <skrald@amossen.dk>
0 siblings, 1 reply; 4+ messages in thread
From: Matthew @ 2007-11-30 13:30 UTC (permalink / raw)
To: pgsql-performance
On Fri, 30 Nov 2007, cluster wrote:
> Can anyone explain the following odd behavior?
> I have a query that completes in about 90 ms. If I append LIMIT to the
> very end, eg. "LIMIT 500" the evaluation time increases to about 800 ms.
> How can performance get *worse* by giving the database the option to
> stop the evaluation earlier (when it reaches the output 500 rows)?
The planner doesn't always get it right. Simple.
Have you done a "VACUUM FULL ANALYSE" recently?
Matthew
--
It is better to keep your mouth closed and let people think you are a fool
than to open it and remove all doubt. -- Mark Twain
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Appending "LIMIT" to query drastically decreases performance
@ 2007-11-30 14:20 Bill Moran <wmoran@collaborativefusion.com>
parent: Matthew <matthew@flymine.org>
0 siblings, 1 reply; 4+ messages in thread
From: Bill Moran @ 2007-11-30 14:20 UTC (permalink / raw)
To: Matthew <matthew@flymine.org>; +Cc: pgsql-performance
In response to Matthew <matthew@flymine.org>:
> On Fri, 30 Nov 2007, cluster wrote:
> > Can anyone explain the following odd behavior?
> > I have a query that completes in about 90 ms. If I append LIMIT to the
> > very end, eg. "LIMIT 500" the evaluation time increases to about 800 ms.
> > How can performance get *worse* by giving the database the option to
> > stop the evaluation earlier (when it reaches the output 500 rows)?
>
> The planner doesn't always get it right. Simple.
>
> Have you done a "VACUUM FULL ANALYSE" recently?
I don't know about the "FULL" part ... but certainly an ANALYZE.
Please post EXPLAIN ANALYZE output for the two queries.
--
Bill Moran
Collaborative Fusion Inc.
http://people.collaborativefusion.com/~wmoran/
wmoran@collaborativefusion.com
Phone: 412-422-3463x4023
****************************************************************
IMPORTANT: This message contains confidential information and is
intended only for the individual named. If the reader of this
message is not an intended recipient (or the individual
responsible for the delivery of this message to an intended
recipient), please be advised that any re-use, dissemination,
distribution or copying of this message is prohibited. Please
notify the sender immediately by e-mail if you have received
this e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The
sender therefore does not accept liability for any errors or
omissions in the contents of this message, which arise as a
result of e-mail transmission.
****************************************************************
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Appending "LIMIT" to query drastically decreases performance
@ 2007-11-30 16:01 cluster <skrald@amossen.dk>
parent: Bill Moran <wmoran@collaborativefusion.com>
0 siblings, 0 replies; 4+ messages in thread
From: cluster @ 2007-11-30 16:01 UTC (permalink / raw)
To: Bill Moran <wmoran@collaborativefusion.com>
> Please post EXPLAIN ANALYZE output for the two queries.
As I wrote in my first post, I pasted this together with the two queries
at pastebin.com:
http://pastebin.com/m3c0d1896
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2007-11-30 16:01 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-11-30 11:16 Appending "LIMIT" to query drastically decreases performance cluster <skrald@amossen.dk>
2007-11-30 13:30 ` Matthew <matthew@flymine.org>
2007-11-30 14:20 ` Bill Moran <wmoran@collaborativefusion.com>
2007-11-30 16:01 ` cluster <skrald@amossen.dk>
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