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个类别的规则,按影响优先级排序,可指导自动化查询优化与schema设计。

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查询语句或设计数据库schema
  • 实现索引或查询优化
  • 排查数据库性能问题
  • 配置连接池或进行扩容
  • 针对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-
4Schema设计
schema-
5并发与锁机制中高
lock-
6数据访问模式
data-
7监控与诊断中低
monitor-
8高级特性
advanced-

How to Use

使用方法

Read individual rule files for detailed explanations and SQL examples:
rules/query-missing-indexes.md
rules/schema-partial-indexes.md
rules/_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示例:
rules/query-missing-indexes.md
rules/schema-partial-indexes.md
rules/_sections.md
每个规则文件包含:
  • 规则重要性的简要说明
  • 错误SQL示例及解释
  • 正确SQL示例及解释
  • 可选的EXPLAIN输出或指标
  • 额外背景信息及参考资料
  • Supabase专属说明(如适用)

Full Compiled Document

完整编译文档

For the complete guide with all rules expanded:
AGENTS.md
如需包含所有规则的完整指南,请查看:
AGENTS.md

When to Use

适用场景

This skill is applicable to execute the workflow or actions described in the overview.
本技能适用于执行概述中描述的工作流或操作。