Use when writing, reviewing, or optimizing Postgres queries, designing schemas, working with RLS, or configuring databases.
Comprehensive performance optimization guide for Postgres, maintained by Supabase. Contains rules across 8 categories, prioritized by impact to guide automated query optimization and schema design.
Reference these guidelines when:
| Priority | Category | Impact | Prefix |
|---|---|---|---|
| 1 | Query Performance | CRITICAL | query- |
| 2 | Connection Management | CRITICAL | conn- |
| 3 | Security & RLS | CRITICAL |
security- |
| 4 | Schema Design | HIGH | schema- |
| 5 | Concurrency & Locking | MEDIUM-HIGH | lock- |
| 6 | Data Access Patterns | MEDIUM | data- |
| 7 | Monitoring & Diagnostics | LOW-MEDIUM | monitor- |
| 8 | Advanced Features | LOW | advanced- |
digraph postgres_workflow {
rankdir=TD;
node [shape=box, style=filled, fillcolor="#f9f9f9"];
start [label="Postgres Task\n(Query, Schema, Config)", shape=oval, fillcolor="#ffdce0"];
identify [label="1. Identify Category\n(Priority 1-8)", fillcolor="#e2f0cb"];
read_rules [label="2. READ rule files\n(e.g., rules/query-missing-indexes.md)", fillcolor="#ffebbb"];
apply [label="3. Apply Correct SQL Pattern", fillcolor="#c7ceea"];
explain [label="4. Verify with EXPLAIN\n(if applicable)", fillcolor="#d4edda"];
end [label="Done", shape=oval, fillcolor="#d4edda"];
start -> identify;
identify -> read_rules;
read_rules -> apply;
apply -> explain;
explain -> end;
}
Read individual rule files for detailed explanations and SQL examples:
rules/query-missing-indexes.md
rules/schema-partial-indexes.md
rules/_sections.md
Each rule file contains:
For the complete guide with all rules expanded: AGENTS.md