Why this matters
Prevents full scans and reduces latency under load.
Identify hot lookups/joins/sorts and add appropriate single/compound indexes in migrations.
Prevents full scans and reduces latency under load.
Side-by-side examples engineers can pattern-match during review.
-- missing index on (org_id, created_at)
SELECT * FROM events WHERE org_id = ? ORDER BY created_at DESC;CREATE INDEX CONCURRENTLY idx_events_org_created ON events(org_id, created_at DESC);WHERE user_id = ? -- no indexCREATE INDEX idx_users_user_id ON users(user_id)From the same buckets as this rule.
Review SQL/database migrations for operations that can lock large tables or cause downtime. Examples: creating indexes without CONCURRENTLY (Postgres), ALTER COLUMN TYPE on big tables, adding NOT NULL without backfill, long-running updates without batching. Require an online migration strategy (CONCURRENTLY, backfill in batches, dual-write/expand-contract) and a rollback plan.