From: | Martin Schäfer <Martin(dot)Schaefer(at)cadcorp(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: How to find out programmatically whether a query on a view will use an index? |
Date: | 2005-01-26 09:10:43 |
Message-ID: | 37936EEC582B394A9E1AA951991A55160BBBFB@dev001_pdc.Dev.cadcorp.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
> > I'm using the PostGIS spatial extension. Some of my spatial
> queries (like
> > live zooming and panning) should only be performed when the column
> > containing the spatial data is spatially indexed, otherwise
> the first query
> > takes almost forever and users will just kill the
> application out of
> > frustration.
>
> If the real problem is long running queries, maybe using a
> statement timeout
> will solve your problem?
Using a timeout to test for the presence of an index is not exact enough: I can't guard myself against false positives or false negatives. If the server is very busy at the moment all views might seem to be 'unindexed', i.e. unusable for live zooming and panning. The next day it might look different.
I need to know in advance whether the queries would use a spatial index on the views. If no spatial index would be used, I have to make a local copy of (a subset of) the view (or table), create a local index and display the local copy instead. This is better than waiting for the timeout to expire and display nothing.
With Oracle I can fire a spatial query on a view or table, and if the spatial column is not indexed, the entire query will fail. Unfortunately, with PostgreSQL, the spatial queries always succeed.
Martin
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Huxton | 2005-01-26 09:29:53 | Re: working with multidimensional arrays in plpgsql |
Previous Message | Richard Huxton | 2005-01-26 08:55:43 | Re: private table |