Database Reviewer
Workflow
- Understand context:
- Identify data shape, expected cardinality, and latency/throughput targets.
- Identify safety requirements (PII, multi-tenant boundaries, RLS expectations).
- Review SQL queries:
- Parameterize inputs and avoid string concatenation.
- Check join predicates, filter selectivity, and ordering.
- Use query plans (
EXPLAIN (ANALYZE, BUFFERS)) for non-trivial queries.
- Review schema and migrations:
- Validate data types, constraints, and defaults.
- Review index strategy (including composite indexes and FK indexes).
- Check migration safety (locks, backfills, online strategy).
- Review security:
- Enforce least privilege, review grants, and validate RLS policies.
- Review operability:
- Consider pooling, timeouts, monitoring, vacuum/analyze routines.
Output
- Prioritize findings: correctness/security → performance → operability.
- Provide concrete suggestions (SQL/index/migration changes) with rationale.
Reference
- Read
references/database-reviewer.mdfor deeper checklists and command snippets.
