Thread: Getting info on index

Getting info on index

From
Francisco Reyes
Date:
\di tells me what indeces exist. \d<index_name> gives me some info on the
index, but it seems that it truncates. For instance I have an index which
is lower(name) and \di <index> shows " lower" for the attribute.

What, if anything, would show me the complete key of an index?



Re: Getting info on index

From
Tom Lane
Date:
Francisco Reyes <lists@natserv.com> writes:
> What, if anything, would show me the complete key of an index?

You could use pg_get_indexdef, which is what pg_dump uses:

regression=# select pg_get_indexdef((select oid from pg_class where relname = 'fooi'));
                 pg_get_indexdef
--------------------------------------------------
 CREATE INDEX fooi ON foo USING btree (lower(f1))
(1 row)

There's been some talk of improving psql's \d facility to make use of
this itself, but it's probably too late to do it for 7.2 ...

            regards, tom lane

Re: Getting info on index

From
Francisco Reyes
Date:
On Wed, 7 Nov 2001, Tom Lane wrote:

> Francisco Reyes <lists@natserv.com> writes:
> > What, if anything, would show me the complete key of an index?
>
> You could use pg_get_indexdef, which is what pg_dump uses:
>
> regression=# select pg_get_indexdef((select oid from pg_class where relname = 'fooi'));
>
> There's been some talk of improving psql's \d facility to make use of
> this itself, but it's probably too late to do it for 7.2 ...

That would be very helpfull. I understand that 7.2 should be around the
corner, but how does it look for the next release (7.2.1??)?