$npx -y skills add supabase/agent-skills --skill supabase-postgres-best-practicesPostgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.
| 1 | # Supabase Postgres Best Practices |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | ## When to Apply |
| 6 | |
| 7 | Reference these guidelines when: |
| 8 | - Writing SQL queries or designing schemas |
| 9 | - Implementing indexes or query optimization |
| 10 | - Reviewing database performance issues |
| 11 | - Configuring connection pooling or scaling |
| 12 | - Optimizing for Postgres-specific features |
| 13 | - Working with Row-Level Security (RLS) |
| 14 | |
| 15 | ## Rule Categories by Priority |
| 16 | |
| 17 | | Priority | Category | Impact | Prefix | |
| 18 | |----------|----------|--------|--------| |
| 19 | | 1 | Query Performance | CRITICAL | `query-` | |
| 20 | | 2 | Connection Management | CRITICAL | `conn-` | |
| 21 | | 3 | Security & RLS | CRITICAL | `security-` | |
| 22 | | 4 | Schema Design | HIGH | `schema-` | |
| 23 | | 5 | Concurrency & Locking | MEDIUM-HIGH | `lock-` | |
| 24 | | 6 | Data Access Patterns | MEDIUM | `data-` | |
| 25 | | 7 | Monitoring & Diagnostics | LOW-MEDIUM | `monitor-` | |
| 26 | | 8 | Advanced Features | LOW | `advanced-` | |
| 27 | |
| 28 | ## How to Use |
| 29 | |
| 30 | Read individual rule files for detailed explanations and SQL examples: |
| 31 | |
| 32 | ``` |
| 33 | references/query-missing-indexes.md |
| 34 | references/query-partial-indexes.md |
| 35 | references/_sections.md |
| 36 | ``` |
| 37 | |
| 38 | Each rule file contains: |
| 39 | - Brief explanation of why it matters |
| 40 | - Incorrect SQL example with explanation |
| 41 | - Correct SQL example with explanation |
| 42 | - Optional EXPLAIN output or metrics |
| 43 | - Additional context and references |
| 44 | - Supabase-specific notes (when applicable) |
| 45 | |
| 46 | ## References |
| 47 | |
| 48 | - https://www.postgresql.org/docs/current/ |
| 49 | - https://supabase.com/docs |
| 50 | - https://wiki.postgresql.org/wiki/Performance_Optimization |
| 51 | - https://supabase.com/docs/guides/database/overview |
| 52 | - https://supabase.com/docs/guides/auth/row-level-security |