DBGorilla Learn
Postgres performance without the guesswork — clear guides to query plans, indexes, locks, and the AI-generated SQL traps that keep showing up.
Query performance & diagnosis
- How to identify slow queries in PostgreSQL — rank real load with
pg_stat_statements(sort by total exec time, not mean). - What pg_stat_statements tells you (and what it doesn't) — what the view captures, what it can't, and how to read it.
- How to read a PostgreSQL EXPLAIN ANALYZE plan — estimated vs actual rows, scan types, and the misestimate signal.
- Why did my PostgreSQL query suddenly get slow? — plan flips, stale stats, and how to get the index back.
- How to find N+1 queries in PostgreSQL — the most common ORM performance bug: spot it, confirm it, fix it with eager loading.
- How to find missing indexes in PostgreSQL — spot sequential scans on big tables; review unused indexes before dropping.
- How to fix high CPU on a PostgreSQL database — trace it to the query, not the config knob.
Indexing
- Which PostgreSQL index type should I use? — B-tree, GIN, GiST, BRIN, SP-GiST, Hash, and when each wins.
- How to add a Postgres index without downtime —
CREATE INDEX CONCURRENTLY, its caveats, and recovering from a failed build.
Migrations & schema changes
- Which ALTER TABLE statements lock a Postgres table — which operations rewrite or scan under ACCESS EXCLUSIVE, and how to avoid the stall.
- How to add a NOT NULL column safely in PostgreSQL — the metadata-only fast path and the safe backfill sequence for big tables.
Locks, transactions & connections
- Understanding lock contention in PostgreSQL —
pg_locks,pg_blocking_pids(), lock modes, and deadlocks. - How to fix "idle in transaction" connections — the open transaction that holds locks and blocks vacuum.
- PostgreSQL connection pooling: fixing "too many connections" — why each connection is a process, and why pooling beats a bigger limit.
Database health
- What is table bloat in PostgreSQL and how to fix it — MVCC dead tuples, VACUUM vs VACUUM FULL, and pg_repack.
AI-generated code
- Why AI-generated SQL is slow — and how to catch it — the database-blindness gap: N+1s, missing indexes, non-sargable predicates.
- How to optimize ORM-generated queries — eager loading across Django/Rails/Prisma/Sequelize, FK indexes, and keyset pagination.
- Common PostgreSQL mistakes AI coding agents make — the whole cluster in one checklist.
DBGorilla connects read-only and gives your AI coding agent (Claude Code, Cursor) your real database context — so it stops guessing about the one system it can't see. Get started free