Last active
February 16, 2020 17:34
-
-
Save garethrees/42ca8dd64182515d6aa90000463ebfe1 to your computer and use it in GitHub Desktop.
List all indexes in postgres database
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT indexname FROM pg_indexes; |
@runekaagaard is it possible to make the parser handle both versions?
-- select indexes of tables in schema "public" --
select * from pg_indexes where schemaname = 'public';
The table has columns schemaname
, tablename
, indexname
, tablespace
, and SQL query of creation in indexdef
.
Excluding pg_catalog
may be a more useful approach if you are looking for some particular indices:
SELECT indexname FROM pg_indexes WHERE schemaname!='pg_catalog'
Wow, didn't realise this was getting so much attention. I don't think I'd been getting emails about gists until this week – perhaps its a new GitHub thing. Anyway, fixed :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
👍 👍 👍 It also shows you additional info that way. On the other hand, if you use
select * from pg_indexes;
you also get to see the index definitions.