---
id: supabase-postgres-best-practices
name: "supabase-postgres-best-practices"
url: https://skills.yangsir.net/skill/supabase-postgres-best-practices
author: supabase
domain: ai-data-management-analysis
tags: ["supabase", "postgresql", "database-design", "sql-optimization", "realtime-databases"]
install_count: 455900
rating: 4.90 (2000 reviews)
github: https://github.com/supabase/agent-skills
---

# supabase-postgres-best-practices

> Supabase Postgres性能优化专家,提供数据库架构设计、查询优化、索引策略等最佳实践指导,帮助开发者编写高效的SQL语句,提升应用性能,适合数据库管理员和后端工程师日常使用。

**Stats**: 455,900 installs · 4.9/5 (2000 reviews)

## Before / After 对比

### 优化Supabase Postgres，提升数据库性能

## Readme

# 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

- 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: https://skills.yangsir.net/skill/supabase-postgres-best-practices*
*Markdown mirror: https://skills.yangsir.net/api/skill/supabase-postgres-best-practices/markdown*