how can I detect GIN and GiST indexes in postgresql? I am looking for if an database of postgres use fulltext. I think that a table use GIN o GiST then is using fulltext.
I accept that GIN or GiST indexes does not necessarily mean that they are used for full text search, but how can I differentiate them of other indexes type? I want to list Gin an Gist indexes
Index definitions can be recreated with pg_get_indexdef()
from the System Catalog Information Functions, fed by the pg_index
system view. The output is theorically non-trivial to parse but in practice, a simple regexp is good enough to filter these definitions on certain index types.
For example, to find gist
or gin
indexes, you may use a query like this:
SELECT pg_get_indexdef(indexrelid) from pg_index
WHERE pg_get_indexdef(indexrelid) ~ 'USING (gin |gist )';
To find if a certain database uses fulltext, I'd probably search for tsvector
columns instead, with a query like this:
SELECT table_schema,table_name, column_name
FROM information_schema.columns
WHERE data_type='tsvector';