Showing Indexes in Postgresql

OK. If you want to see the indexes to a table in Postgresql you can do this here:

\d <TABLENMAE>

If that is not showing what you expected you can do this short sql statement.


select
 t.relname as table_name,
 i.relname as index_name,
 a.attname as column_name
from
 pg_class t,
 pg_class i,
 pg_index ix,
 pg_attribute a
where
 t.oid = ix.indrelid
 and i.oid = ix.indexrelid
 and a.attrelid = t.oid
 and a.attnum = ANY(ix.indkey)
 and t.relkind = 'r'
 and t.relname like 'not%'
order by
 t.relname,
 i.relname;

That shows all indexes which are beginning with “not”.

I heard from other database where you just have to type in “show indexes”. But why make it so easy if it can be so difficult.

The usability of postgresql is incredible bad!

Published by Robert Reiz

CEO @ VersionEye. Passionated software developer since 1998.

3 thoughts on “Showing Indexes in Postgresql

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: