Is there a way to easily check if a PostgreSQL database has any GiST indexes and of what type they are?
Asked
Active
Viewed 356 times
1 Answers
5
Whenever you need to examine the structure of your database via code, always think "I should look at information_schema or pg_catalog". information_schema contains a standardized schema (66 views), whereas pg_catalog is PostgreSQL-specific, but contains more info (97 tables or views).
select
*
from
pg_catalog.pg_indexes
where
indexdef ~* '\ygist\y'
Will show you all the gist indexes and their tables, names, and definitions.
~* means match a regular expression, case-insensitive.
\y means word boundary, so it would find ' gist ' but not 'logistics' in that column
Neil McGuigan
- 7,653
- 3
- 36
- 52
-
Thanks! This worked! The command did not produce any results, but that was somewhat expected as most of our indexes are btree. – user972276 Aug 08 '14 at 16:02