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

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: 2007-11-30 11:16:08
Message-ID: fiordm$2aev$1@news.hub.org (view raw or flat)
Thread:
Lists: 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

Responses

pgsql-performance by date

Next:From: MatthewDate: 2007-11-30 13:30:28
Subject: Re: Appending "LIMIT" to query drastically decreases performance
Previous:From: Csaba NagyDate: 2007-11-30 10:29:43
Subject: Re: TB-sized databases

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