Re: Query to retrieve all indexed columns

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Bart van Houdt" <bart(dot)van(dot)houdt(at)syfact(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Query to retrieve all indexed columns
Date: 2008-11-19 18:24:26
Message-ID: 8307.1227119066@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

"Bart van Houdt" <bart(dot)van(dot)houdt(at)syfact(dot)com> writes:
> I am working on a query to retrieve all indexed columns and came up with
> the following query:
> ...
> Tis query works for single column indexes, but with multiple column
> indexes I get incorrect results... I'm having a hard time figuring out
> how to join pg_attribute.indkey in this, could anyone help me out on
> this one?

Look at the information_schema views. You might find that one of them
already solves your problem ... and even if not, they will provide
examples of how to deconstruct the catalog information.
share/information_schema.sql in an installed PG file set is the
most convenient thing to study.

regards, tom lane

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message novice 2008-11-20 02:10:41 date range query help
Previous Message Richard Huxton 2008-11-19 18:05:57 Re: VACUUM cannot be executed from multi-command string