supabase-postgres-best-practices

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Supabase Postgres Best Practices

Supabase Postgres 最佳实践

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.
这是由Supabase维护的Postgres全面性能优化指南。包含8个类别的规则,按影响优先级排序,可指导自动化查询优化和架构设计。

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)
参考这些指南的场景:
  • 编写SQL查询或设计数据库架构
  • 实现索引或查询优化
  • 排查数据库性能问题
  • 配置连接池或进行扩容
  • 针对Postgres特定功能进行优化
  • 使用行级安全性(Row-Level Security, RLS)

Rule Categories by Priority

按优先级划分的规则类别

PriorityCategoryImpactPrefix
1Query PerformanceCRITICAL
query-
2Connection ManagementCRITICAL
conn-
3Security & RLSCRITICAL
security-
4Schema DesignHIGH
schema-
5Concurrency & LockingMEDIUM-HIGH
lock-
6Data Access PatternsMEDIUM
data-
7Monitoring & DiagnosticsLOW-MEDIUM
monitor-
8Advanced FeaturesLOW
advanced-
优先级类别影响程度前缀
1查询性能关键
query-
2连接管理关键
conn-
3安全与RLS关键
security-
4架构设计
schema-
5并发与锁中高
lock-
6数据访问模式
data-
7监控与诊断中低
monitor-
8高级功能
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)
阅读单个规则文件以获取详细说明和SQL示例:
references/query-missing-indexes.md
references/schema-partial-indexes.md
references/_sections.md
每个规则文件包含:
  • 简要说明该规则的重要性
  • 错误的SQL示例及解释
  • 正确的SQL示例及解释
  • 可选的EXPLAIN输出或指标
  • 额外的背景信息和参考资料
  • 特定于Supabase的说明(如适用)

References

参考资料