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

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Appending "LIMIT" to query drastically decreases performance


  • From: cluster <skrald(at)amossen(dot)dk>
  • To: pgsql-performance(at)postgresql(dot)org
  • Subject: Appending "LIMIT" to query drastically decreases performance
  • Date: Fri, 30 Nov 2007 12:16:08 +0100
  • Message-id: <fiordm$2aev$1@news.hub.org> <text/plain>

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



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group