[SQL] How to find out programmatically whether a query on a view will use an index?

2005-01-24 Thread Martin Schäfer
Hi, 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 frus

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

2005-01-24 Thread Tom Lane
=?iso-8859-1?Q?Martin_Sch=E4fer?= <[EMAIL PROTECTED]> writes: > Using 'EXPLAIN SELECT ...' does tell me whether the spatial index is used, > but the output is not machine readable. I guess the output is localized to > the current locale, AFAIK it's not localized, so grepping for "Index" would pr

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

2005-01-24 Thread Martin Schäfer
> > Is there no way to get a machine readable query plan? > > No, and no such API is likely to be defined in the future either, > because we reserve the right to change plan structures at any time. How about a list of the indices used in a query? That alone would already be very useful. Martin

Re: [SQL] update from multiple rows

2005-01-24 Thread franco
I understand data_sys is the average value for the 3 days, from at the (Bday before to the day after. (BThis should do what you want, in one pass. Check the average function in (Bthe subselect. If what you want is to divide by 3 no matter how many (Brecords where found, enable the commented lin

[SQL] Value specific sequences?

2005-01-24 Thread Dmitri Bichko
Hello everyone, I have a table of entities, each entity has a parent_id, I'd like to have an insert trigger that assigns to that entity a sequential number which gets incremented per parent_id. i.e. doing: INSERT INTO foo(id, parent_id) VALUES('a',1); INSERT INTO foo(id, parent_id) VALUES('b',1);