返回全部 Skills

supabase-postgres-best-practices

开发工具

来自Supabase的Postgres性能优化和最佳实践。在编写、审查或优化Postgres查询、模式设计或数据库配置时使用此技能。

151.8k

下载量

AI SkillHub 能力展示图

安装方式

命令行安装

在项目根目录执行以下命令,完成 Skill 安装。

npx bzskills add supabase/agent-skills --skill supabase-postgres-best-practices

skill.md

name: supabase-postgres-best-practices
description: 来自Supabase的Postgres性能优化和最佳实践。在编写、审查或优化Postgres查询、模式设计或数据库配置时使用此技能。
license: MIT
metadata:
    author: supabase
    version: "1.1.1"
    organization: Supabase
    date: January 2026
    abstract: Comprehensive Postgres performance optimization guide for developers using Supabase and Postgres. Contains performance rules across 8 categories, prioritized by impact from critical (query performance, connection management) to incremental (advanced features). Each rule includes detailed explanations, incorrect vs. correct SQL examples, query plan analysis, and specific performance metrics to guide automated optimization and code generation.

Supabase Postgres 最佳实践

由 Supabase 维护的 Postgres 综合性能优化指南。包含按影响优先级排列的 8 个类别规则,用于指导自动化查询优化与 schema 设计。

何时应用

在以下场景中请参考本指南:

  • 编写 SQL 查询或设计 schemas
  • 实施索引或查询优化
  • 审查数据库性能问题
  • 配置连接池或扩展
  • 优化 Postgres 特定功能
  • 使用行级安全(RLS)

按优先级分类的规则

优先级类别影响前缀
1查询性能关键query-
2连接管理关键conn-
3安全与 RLS关键security-
4Schema 设计schema-
5并发与锁定中-高lock-
6数据访问模式data-
7监控与诊断低-中monitor-
8高级功能advanced-

如何使用

阅读各规则文件以获取详细解释和 SQL 示例:

references/query-missing-indexes.md
references/query-partial-indexes.md
references/_sections.md

每个规则文件包含:

  • 该规则重要性的简要说明
  • 错误的 SQL 示例及解释
  • 正确的 SQL 示例及解释
  • 可选的 EXPLAIN 输出或指标
  • 额外上下文和参考资料
  • Supabase 特定说明(如适用)

参考资料

  • 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