[postgis-users] PostGIS supresses the "LIMIT" optimization?

Mark Cave-Ayland mark.cave-ayland at ilande.co.uk
Thu Aug 16 15:28:10 PDT 2007


On Thu, 2007-08-16 at 10:52 -0700, Michael Smedberg wrote:
> I believe that Postgres has an optimization that “short-circuits” plan
> execution when the SQL contains a LIMIT clause, but no “order by” or
> other function that requires the whole result set.  It seems like
> PostGIS turns this optimization off (I’m using PostGIS 1.2.1.)  Is
> this a known bug?  Is there a workaround that would allow me to have
> poorly constrained GIS queries return quickly (if it’s poorly
> constrained, I don’t care about the results, I just want to know that
> there are too many to display)?  In other words, is there a way for me
> to KNOW it’s poorly constrained without having to wait for the whole
> (large) result set to be generated?

(cut)

> I’m a newbie to this list, so please forgive me if this is a dumb
> question…

No, it's actually a good question :)

The first thing to notice is that your queries are different because
your second query has a WHERE clause - does your first query behave any
differently with a WHERE clause added? Make sure you choose a condition
that selects a similar percentage of the table as a good test.


HTH,

Mark.

-- 
ILande - Open Source Consultancy
http://www.ilande.co.uk





More information about the postgis-users mailing list