PostGIS – How to Check If a Geometry Column Has Spatial Indexing for Optimized Queries

postgis

I do not have access to DDL / write access of the database. How do I check if existing geometry columns have spatial indexing implemented or not?

Best Answer

You can find a list of all indexes on a table with:

SELECT indexname, indexdef FROM pg_indexes WHERE tablename = 'name' AND schemaname = 'schema';

which will give a result like:

"brownsh_pkey"  "CREATE UNIQUE INDEX brownsh_pkey ON boundaries.brownsh USING btree (ogc_fid)"
"brownsh_geom_idx"  "CREATE INDEX brownsh_geom_idx ON boundaries.brownsh USING gist (wkb_geometry)"
"brownsh_pk"    "CREATE UNIQUE INDEX brownsh_pk ON boundaries.brownsh USING btree (ogc_fid)"