X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EA02C3A54FF for ; Mon, 24 Jan 2005 16:32:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 56760-09 for ; Mon, 24 Jan 2005 16:32:44 +0000 (GMT) Received: from smarthost1.mail.uk.easynet.net (smarthost1.mail.uk.easynet.net [212.135.6.11]) by svr1.postgresql.org (Postfix) with ESMTP id F01063A5435 for ; Mon, 24 Jan 2005 16:32:43 +0000 (GMT) Received: from [195.40.158.200] (helo=dev001_pdc.Dev.cadcorp.net) by smarthost1.mail.uk.easynet.net with esmtp (Exim 4.10) id 1Ct78p-000Jl3-00 for pgsql-sql@postgresql.org; Mon, 24 Jan 2005 16:32:39 +0000 content-class: urn:content-classes:message Subject: How to find out programmatically whether a query on a view will use an index? MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Mon, 24 Jan 2005 16:34:09 -0000 X-MimeOLE: Produced By Microsoft Exchange V6.0.6249.0 Message-ID: <37936EEC582B394A9E1AA951991A551609D274@dev001_pdc.Dev.cadcorp.net> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: How to find out programmatically whether a query on a view will use an index? Thread-Index: AcUCMocLauy7wXvQRkui+whuJ2+X2Q== From: =?iso-8859-1?Q?Martin_Sch=E4fer?= To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.818 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/209 X-Sequence-Number: 19997 Hi, I'm using the PostGIS spatial extension. Some of my spatial queries = (like=20 live zooming and panning) should only be performed when the column=20 containing the spatial data is spatially indexed, otherwise the first = query=20 takes almost forever and users will just kill the application out of=20 frustration. I can easily find out whether a spatial column in a table is spatially=20 indexed, using pg_class, pg_index, and pg_opclass. But this doesn't work = for=20 views. I can't find out whether a column in a view, is just an 'exact = copy'=20 of a column in a table (indicating that there's a chance that an index = on=20 the table column could be used for a query on the view column), or = whether=20 the column in the view defines some kind of operation, rendering any=20 possible index on the table column useless.