Re: How to find out programmatically whether a query on a view will use an index?

Поиск
Список
Период
Сортировка
От Martin Schäfer
Тема Re: How to find out programmatically whether a query on a view will use an index?
Дата
Msg-id 37936EEC582B394A9E1AA951991A55160BBBFB@dev001_pdc.Dev.cadcorp.net
обсуждение исходный текст
Ответ на How to find out programmatically whether a query on a view will use an index?  (Martin Schäfer <Martin.Schaefer@cadcorp.com>)
Список 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
orfalse negatives. If the server is very busy at the moment all views might seem to be 'unindexed', i.e. unusable for
livezooming 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
willfail. Unfortunately, with PostgreSQL, the spatial queries always succeed. 

Martin


В списке pgsql-sql по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: private table
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: working with multidimensional arrays in plpgsql