From: Martin Schäfer <Martin.Schaefer@cadcorp.com>
To: pgsql-sql@postgresql.org
Subject: Find out whether a view's column is indexed?
Date: Thu, 10 Jun 2004 08:56:05 +0100
Message-ID: <37936EEC582B394A9E1AA951991A551604C3BF@dev001_pdc.Dev.cadcorp.net> (raw)
Is there any way to find out whether a column that's used in a view is indexed?
The following query:
SELECT ic.relname AS index_name
FROM pg_class bc,
pg_class ic,
pg_index i,
pg_attribute a,
pg_opclass oc,
pg_namespace n
WHERE i.indrelid = bc.oid AND
i.indexrelid = ic.oid AND
i.indkey[0] = a.attnum AND
i.indclass[0] = oc.oid AND
a.attrelid = bc.oid AND
oc.opcname = 'gist_geometry_ops' AND
n.oid = bc.relnamespace AND
bc.relkind ~ '[rv]' AND
ic.relkind = 'i' AND
n.nspname = 'foo' AND
bc.relname = 'bar' AND
a.attname = 'foobar';
lets me find out whether a table column is indexed, but it doesn't work for views. Is there anything that can be done for views? At least for simple views of the kind 'CREATE VIEW v AS SELECT a,b,c FROM t'?
Can anybody help?
Martin
PS: as you can see from the query I'm using the PostGIS extension, and I'm only interested in spatial indices on geometry columns.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: Martin.Schaefer@cadcorp.com
Subject: Re: Find out whether a view's column is indexed?
In-Reply-To: <37936EEC582B394A9E1AA951991A551604C3BF@dev001_pdc.Dev.cadcorp.net>
References: <37936EEC582B394A9E1AA951991A551604C3BF@dev001_pdc.Dev.cadcorp.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox