---
title: "Supabase Postgres Best Practices: review, setup & limitations · Undominated.ai"
canonical: https://undominated.ai/skills/supabase-supabase-postgres-best-practices/
description: "Connects Postgres schema and query decisions to worked SQL examples, connection guidance and row-level security checks."
---

# Supabase Postgres Best Practices: review, setup & limitations · Undominated.ai

> Connects Postgres schema and query decisions to worked SQL examples, connection guidance and row-level security checks.

[← Explore all skills](/skills/)

DATABASES / Supabase

# Supabase Postgres Best Practices

Connects Postgres schema and query decisions to worked SQL examples, connection guidance and row-level security checks.

 [See setup guidance ↓](#setup)[Original source ↗](https://github.com/supabase/agent-skills/tree/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices)

SOURCE REVIEW

 Reviewed 2026-10-13
 Evidence 7 linked sources
 Publisher Supabase
 Licence [MIT ↗](https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/LICENSE)
 Revision c9be0e931b79
 [Read what was—and wasn’t—checked ↓](#review)

“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.”

 [Supabase · upstream description ↗](https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/SKILL.md) Our analysis follows below.

01 / THE REASONING

## Why this made the selection.

 - Pairs incorrect and corrected SQL with query-plan examples instead of offering only generic database advice.
- Treats row-level security, privileges and connection management as part of database work rather than a separate performance afterthought.

### A good fit for

 - Reviewing a Postgres migration or slow query
- Checking tenant-isolation policies and supporting indexes
- Writing an RLS policy that evaluates auth.uid() once per query instead of once per row

### Weigh up before choosing

 - Illustrative speedups and blanket indexing rules are not measurements of your workload; inspect actual plans and write costs.
- Security-definer and RLS examples require privilege-aware adaptation and tests against the target schema.
- The description triggers on pg_cron, pgmq, pgvector and pg_restore work, but none of the 34 files under references/ mentions those names; the 31 rule files cover queries, connections, security, schema, locking, data access, monitoring, full-text search and JSONB.

02 / THE REVIEW RECORD

## What we actually inspected.

Source review has boundaries. A clear record is more useful than a “safe” badge.

### Material inspected

 - skills/supabase-postgres-best-practices/SKILL.md
- skills/supabase-postgres-best-practices/references/query-missing-indexes.md
- skills/supabase-postgres-best-practices/references/security-rls-performance.md
- skills/supabase-postgres-best-practices/references/_sections.md
- skills/supabase-postgres-best-practices/CHANGELOG.md
- skills/supabase-postgres-best-practices/references/ (all 34 bundled files scanned for shell blocks and URLs: SQL examples and supabase.com or postgresql.org links only)
- README.md installation section
- LICENSE

### Our findings

 - The definition routes work to named rules for queries, connections, schema, locking and RLS.
- The inspected missing-index rule contrasts sequential and index scans using a concrete WHERE/JOIN example.
- The RLS reference warns that security-definer functions bypass table policies and calls for caller checks, a non-exposed schema and restricted execution.
- Frontmatter metadata says version 1.1.1, while CHANGELOG.md in the same directory tops out at 1.6.0 (2026-07-30).
- The rule files carry publisher impact figures such as 100-1000x for missing indexes and 5-10x for RLS patterns; none is a measurement of your workload.
- Re-pinned from 8331f910845103c08d51f6ca1d86ebb7d1f745e3 to c9be0e931b7930f7d02126d04774d904c381e7d7: GitHub's compare lists four changed files, none under skills/supabase-postgres-best-practices, and LICENSE and README.md are unchanged. The earlier upstreamDescription was cut mid-sentence and now carries the full frontmatter text.

### Not established by this review

 - No SQL was executed against a database.
- Workload performance and tenant-isolation behavior were not measured.

The review applies to the material and revision named here. A newer upstream release can change its behavior.

03 / PUT IT TO WORK

## Add a skill to your workflow.

[Upstream setup instructions ↗](https://github.com/vercel-labs/skills/blob/7407f3893ad4dceab546ac002c3ef806e4000c73/README.md)

DOCUMENTED COMMAND

 npx skills add supabase/agent-skills/skills/supabase-postgres-best-practices Copy command ↗

Run in your terminal to choose your AI tools, project or global scope, and installation method. This short command follows the current upstream version; the review covers the revision shown above.

 Optional: install the reviewed revision

Keeps the original source and installer version where recorded, while leaving your AI tools and installation scope for you to choose.

 npx skills add https://github.com/supabase/agent-skills/tree/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices Copy reviewed-revision command ↗ - Install the complete skill directory with its references and helpers; a copied SKILL.md alone may be incomplete.
- Choose your AI tools and project or global scope in the installer, then review its permissions before using the skill.
- For manual installation instead, download the complete bundle from https://undominated.ai/resources/skills/supabase-supabase-postgres-best-practices/bundle.zip and extract it into a new directory. It holds SKILL.md and 35 supporting files unchanged at revision c9be0e93, the upstream licence and an attribution file.
- Place the extracted directory in your host's documented skills directory, named supabase-postgres-best-practices. Keep SKILL.md and the licence together.

### Before you start

 - Node.js/npm for this installer
- An agent that supports the Agent Skills format
- Access to the relevant schema and query plans; database credentials only if you choose to run checks

### Compatibility

Agent Skills-compatible coding agents · PostgreSQL; Supabase-specific examples are identified

### Database files; optional database access

 - Read schema, SQL and query plans
- Write migration or policy files when authorized
- Executing suggested SQL can create indexes or alter permissions

### Cost model

The instruction package is MIT-licensed; database hosting, query execution and agent usage have their own costs.

THE COMPLETE REVIEWED DEFINITION

## Read it before you reuse it.

Original source bytes, with attribution. Review the host-specific setup notes above.

 Copy definition ↗ [Download complete resource + licence ↗](/resources/skills/supabase-supabase-postgres-best-practices/bundle.zip)[Raw Markdown ↗](/resources/skills/supabase-supabase-postgres-best-practices/definition.md)
 ---
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

- 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

The download contains SKILL.md . Extract the whole bundle; the supporting files are required. Inspect the included MANIFEST.json for file hashes.

By **Supabase**. [Exact upstream source ↗](https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/SKILL.md) · [Licence](/resources/skills/supabase-supabase-postgres-best-practices/LICENSE.txt) · [Attribution](/resources/skills/supabase-supabase-postgres-best-practices/ATTRIBUTION.txt)

SHA-256 ad65e776f45e761bafc609d3f506c77c1032225aa65e0c4c02f241b8071e5855

 Read the applicable licence MIT License

Copyright (c) 2026 Supabase

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

04 / FOLLOW THE EVIDENCE

## The source trail.

Our notes are separate from the original resource. Check upstream before adopting a new version.

 - [Skill definition at reviewed revision ↗](https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/SKILL.md) Checked 2026-10-13 https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/SKILL.md Supports: summary, upstreamDescription, whySelected, bestFor, limitations, review, compatibility, access
- [Reviewed reference or helper: references/query-missing-indexes.md ↗](https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/references/query-missing-indexes.md) Checked 2026-10-13 https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/references/query-missing-indexes.md Supports: review, limitations, access
- [Reviewed reference or helper: references/security-rls-performance.md ↗](https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/references/security-rls-performance.md) Checked 2026-10-13 https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/skills/supabase-postgres-best-practices/references/security-rls-performance.md Supports: review, limitations, access, bestFor
- [Upstream license or licensing declaration ↗](https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/LICENSE) Checked 2026-10-13 https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/LICENSE Supports: license
- [Publisher installation and project documentation ↗](https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/README.md) Checked 2026-10-13 https://github.com/supabase/agent-skills/blob/c9be0e931b7930f7d02126d04774d904c381e7d7/README.md Supports: install, compatibility, access
- [Skills installer source formats and selective installation ↗](https://github.com/vercel-labs/skills/blob/7407f3893ad4dceab546ac002c3ef806e4000c73/README.md) Checked 2026-10-13 https://github.com/vercel-labs/skills/blob/7407f3893ad4dceab546ac002c3ef806e4000c73/README.md Supports: install
- [Installer implementation: full commit SHA fallback ↗](https://github.com/vercel-labs/skills/blob/7407f3893ad4dceab546ac002c3ef806e4000c73/src/git.ts) Checked 2026-10-13 https://github.com/vercel-labs/skills/blob/7407f3893ad4dceab546ac002c3ef806e4000c73/src/git.ts Supports: install

KEEP COMPARING

## Other approaches to consider.

Related by category or shared topics. These are alternatives to inspect, not a measured quality order.

 [### Postgres ↗ Timescale's postgres skill from pg-aiguide: a dispatcher that sends the agent to nine reference guides for schema exploration, table design, pgvector and hybrid search, TimescaleDB hypertables and schema migrations.](/skills/timescale-postgres/)[### CockroachDB SQL ↗ Cockroach Labs skill that turns a natural-language request into CockroachDB SQL, applies the relevant rule files with 00-fundamental-principles.md first, and tells the agent to run EXPLAIN on every generated query when a cluster connection is available.](/skills/cockroachlabs-cockroachdb-sql/)[### dbt Documentation Maintenance ↗ Audits descriptions in a dbt manifest and drafts missing model or column documentation in the project’s existing style.](/skills/dbt-labs-maintaining-dbt-documentation/)

 [AI Tools ↗](/tools/)[Skills ↗](/skills/)[Agents ↗](/agents/)[MCP Servers ↗](/mcp-servers/)[Workflows ↗](/workflows/)

## Continue your investigation

 - [Choose a toolkit](/tools/)
- [Inspect execution hosts](/agents/)
- [Check tool access](/mcp-servers/)
- [Check project dependencies](/check-repo/)
