
Supabase Postgres Best Practices
Skill按影响分级的 Postgres 规则:查询优化、索引、连接池、RLS 安全、schema 设计与锁问题排查,附错误与正确 SQL 对照,适用于任意 Postgres。Supabase 官方维护。
name: supabase-postgres-best-practices
description: "Postgres best practices maintained by Supabase, for Postgres running anywhere. Load this skill BEFORE writing or changing anything that lives in a Postgres database: creating or altering tables and columns (including choosing column types), schema design, migrations and declarative schema files, RLS policies and the tests that verify them, indexes, triggers, database functions, queues and scheduled jobs (pg_cron, pgmq), vector/semantic search (pgvector), and restoring dumps (pg_restore) or importing data. Also load it when diagnosing slow queries, high CPU, timeouts, EXPLAIN plans, connection exhaustion, locking, bloat, or rows visible to the wrong user or tenant. This is not just a performance guide — schema, migration, security, and SQL authoring tasks need these rules too, even for a one-column change or a single query."
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 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/query-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
相關資源

Supabase Agent Plugin
PluginSupabase 官方插件:内置 Supabase 与 Postgres 最佳实践技能,并接入 Supabase 远程 MCP,可管理项目、执行 SQL、设计表结构与 RLS、处理认证和存储。需要 Supabase 账号。
supabase-community/supabase-plugin65
Postgres MCP Pro
MCP面向 PostgreSQL 的 MCP 服务器:数据库健康检查、索引调优、EXPLAIN 执行计划分析与假设索引模拟,受限模式下只读安全执行 SQL。
crystaldba/postgres-mcp3.5k
Supabase MCP Server
MCP连接 Supabase 项目:管理表结构与迁移、执行 SQL、部署 Edge Functions、创建开发分支、生成 TypeScript 类型。Supabase 官方托管的远程服务,OAuth 登录。
supabase/mcp3k
MCP Toolbox for Databases
MCPGoogle 官方开源的数据库 MCP 服务器,预置 PostgreSQL、MySQL、BigQuery、Spanner、MongoDB 等数十种数据源的查表与执行 SQL 工具,也能用 tools.yaml 定义受控的自定义查询。
googleapis/mcp-toolbox17k
SQL Queries
SkillAnthropic 官方数据技能,指导 agent 在 Snowflake、BigQuery、Databricks、PostgreSQL 等主流数仓方言下编写、翻译和优化 SQL,涵盖 CTE、窗口函数与聚合分析查询。
anthropics/knowledge-work-plugins37.4k
Supabase
SkillSupabase 官方通用技能:覆盖数据库、Auth、Edge Functions、Realtime、Storage、向量与队列,以及 supabase-js/SSR 集成、CLI 与 MCP、迁移和 RLS 安全检查,要求先查最新文档与变更日志再动手。
supabase/agent-skills3.2k