How to List Indexes in PostgreSQL
Last updated July 25, 2026 · By the SaturnSQL team
In psql, \di lists indexes and \d tablename shows the indexes on one table. From SQL, query the pg_indexes view, which includes the full index definition.
psql
\di lists indexes across the search_path, while \d orders shows one table with its indexes, constraints, and triggers underneath the column list. Both are psql-only. \di+ adds the index size, which is the quickest way to spot an index that has grown larger than the table it serves.
\di
\d ordersPlain SQL (works from any client)
pg_indexes gives you indexname plus the complete CREATE INDEX statement in indexdef, which is what you want when recreating an index elsewhere or reviewing what a migration actually built. It carries no size information; use pg_relation_size for that, or check idx_scan in pg_stat_user_indexes to find indexes nothing is using.
SELECT indexname, indexdef
FROM pg_indexes
WHERE schemaname = 'public'
AND tablename = 'orders'
ORDER BY indexname;Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free