supabase-postgres-best-practices
Supabase Postgres Best Practices
Section titled “Supabase Postgres Best Practices”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.
When to Apply
Section titled “When to Apply”Reference these guidelines when:
- Writing SQL queries or designing schemas
- Implementing indexes or query optimization
- Reviewing database performance issues
- Configuring connection pooling or scaling
- Optimizing for Postgres-specific features
- Working with Row-Level Security (RLS)
Rule Categories by Priority
Section titled “Rule Categories by Priority”| 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- |
How to Use
Section titled “How to Use”Read individual rule files for detailed explanations and SQL examples:
references/query-missing-indexes.mdreferences/query-partial-indexes.mdreferences/_sections.mdEach rule file contains:
- Brief explanation of why it matters
- Incorrect SQL example with explanation
- Correct SQL example with explanation
- Optional EXPLAIN output or metrics
- Additional context and references
- Supabase-specific notes (when applicable)
References
Section titled “References”- https://www.postgresql.org/docs/current/
- https://supabase.com/docs
- https://wiki.postgresql.org/wiki/Performance_Optimization
- https://supabase.com/docs/guides/database/overview
- https://supabase.com/docs/guides/auth/row-level-security
Source: supabase/agent-skills, official, MIT-licensed.
Reference files
Section titled “Reference files”- Section Definitions
- Advanced Full Text Search
- Advanced Jsonb Indexing
- pgbouncer.ini
- Conn Limits
- Conn Pooling
- Conn Prepared Statements
- Data Batch Inserts
- Data N Plus One
- Data Pagination
- Data Upsert
- Lock Advisory
- Lock Deadlock Prevention
- Lock Short Transactions
- Lock Skip Locked
- Monitor Explain Analyze
- Monitor Pg Stat Statements
- Monitor Vacuum Analyze
- Query Composite Indexes
- Query Covering Indexes
- Query Index Types
- Query Missing Indexes
- Query Partial Indexes
- Schema Constraints
- Schema Data Types
- Schema Foreign Key Indexes
- Schema Lowercase Identifiers
- Schema Partitioning
- Schema Primary Keys
- Security Privileges
- Security Rls Basics
- Security Rls Performance