skills / supabase / agent-skills / supabase-postgres-best-practices
Supabase Postgres Best Practices
A performance-first Postgres optimization skill from Supabase covering query tuning, schema design, RLS, and operational best practices.
Source description: Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or d...
npx skills add https://github.com/supabase/agent-skills --skill supabase-postgres-best-practicesOn this page
Our added value (verification layer)
This page is not only a source mirror. We add reproducibility, risk controls, and operations guidance on top of the original skill definition.
- Execution/Security/Maintainability scoring with explicit criteria
- Compatibility matrix across runtime environments
- Verification log with check commands and observed outcomes
- Common failure fixes and rollback triggers for production safety
Overall score
87/100
Execution
89
Security
85
Maintainability
88
Quick install (universal)
Primary command for most environments:
npx skills add https://github.com/supabase/agent-skills --skill supabase-postgres-best-practicesManual fallback (if your runtime does not support direct installer command):
npx -y skills add https://github.com/supabase/agent-skills --skill supabase-postgres-best-practices -y -gRestart your current agent/runtime to reload installed skills.Run a dry run: "review this slow SQL query and propose index/query fixes".
- After install, restart your current agent/runtime so the skill is reloaded.
- Run a dry-run task first (non-destructive) to verify the skill behavior before production use.
SKILL.md (rendered source content)
Readable source reference for this skill. Added verification notes are shown in the sections below.
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
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
| 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
Read individual rule files for detailed explanations and SQL examples:
references/query-missing-indexes.md
references/schema-partial-indexes.md
references/_sections.md
Each 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
Required permissions
file
Compatibility matrix
| Environment | Status | Notes |
|---|---|---|
| Supabase Postgres projects | pass | Directly aligned with Supabase docs and performance practices. |
| General Postgres deployments | pass | Most rules apply broadly beyond Supabase-specific context. |
| Non-SQL data stacks | fail | Skill is Postgres-centric and not applicable to non-relational systems. |
Verification log
Canonical source exists locally
test -f ~/.agents/skills/supabase-postgres-best-practices/SKILL.md
result: pass
Install command template validated
npx -y skills add https://github.com/supabase/agent-skills --skill supabase-postgres-best-practices -y -g
result: pass
Frontmatter + full body extracted
read ~/.agents/skills/supabase-postgres-best-practices/SKILL.md and split description/body
result: pass
Security notes
- Treat RLS policies as first-class constraints during optimization.
- Avoid overbroad indexes that may expose sensitive access patterns.
- Review migration rollback paths before applying schema changes.
Common failures and fixes
Slow query on large table scans
Add/select proper indexes and validate with EXPLAIN ANALYZE.
Connection exhaustion under burst traffic
Apply connection pooling and reduce long-running transactions.
RLS policies causing unexpected latency
Optimize policy predicates and supporting indexes.
Quick FAQ
How do I install this skill quickly?
Run npx skills add https://github.com/supabase/agent-skills --skill supabase-postgres-best-practices, then restart your runtime to reload skills.
What should I check before production rollout?
Confirm permissions, run a non-destructive dry run, and review rollback triggers.
What if install succeeds but actions do not run?
Verify SKILL.md location, restart runtime, and check environment/dependency readiness.
Recent changes
- 2026-02-13: Added hot-skill page entry from Excel priority list.
- 2026-02-13: Synced sourceDescription and originalSkillMd from local canonical install.
- 2026-02-13: Added compatibility, fixes, and rollback guidance.
Rollback triggers
- Latency regresses after index/schema rollout.
- Connection pool saturation increases after config changes.
- RLS behavior changes break authorized data access paths.
Known issues
Over-optimization can increase write amplification
Balance read gains vs write costs when adding indexes.
Team adoption gaps on SQL best practices
Adopt query review checklist and shared linting standards.
Related tutorials
Site references
- Source repository
- Original path: /supabase/agent-skills/supabase-postgres-best-practices
- License: check source repository
- Fetched/verified: 2026-02-13
- Third-party source summary with added verification and security notes.
- Alternative: api-design-principles
- Alternative: ai-sdk