Postgres Indexing Cheat Sheet

Choose b-tree, GIN, BRIN, and monitor bloat

Last Updated: November 21, 2025

Index Types

Type Use
B-tree Equality + range
GIN JSON/text search
BRIN Large time series
Hash Exact match

Commands

CREATE INDEX ON tbl (col)
Add index
REINDEX TABLE
Rebuild
EXPLAIN ANALYZE query
View plan

Maintenance

Avoid duplicate indexes, drop unused ones, and autovacuum frequently.

💡 Pro Tip: Monitor `pg_stat_user_indexes`, keep indexes selective, and avoid redundant indexes.
← Back to Databases & APIs | Browse all categories | View all cheat sheets