supabase-postgres-best-practices

Applies Postgres performance, schema, security, and migration rules to SQL authoring and optimization tasks.

Updated Feb 21, 2026
One-click install
npx skills add https://github.com/ESSSoWhat/live-translate-realtime-dubbing --skill supabase-postgres-best-practices-esssowhat
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: supabase-postgres-best-practices
Source: https://github.com/ESSSoWhat/live-translate-realtime-dubbing/tree/main/.agents/skills/supabase-postgres-best-practices
Command: npx skills add https://github.com/ESSSoWhat/live-translate-realtime-dubbing --skill supabase-postgres-best-practices-esssowhat

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Writing Postgres schemas, queries, migrations, and RLS policies without established rules leads to slow queries, connection exhaustion, deadlocks, and data leaks. This Skill provides a prioritized rule set maintained by Supabase so every database change follows proven best practices. ## Core Features & Use Cases - Prioritized Rule Categories: Eight categories ranked by impact, from query performance and connection management (critical) to advanced features like full-text search and JSONB indexing. - Incorrect vs. Correct SQL Examples: Each rule file shows the anti-pattern first, then the optimized rewrite, with quantified impact such as 100x faster queries or 50% smaller indexes. - Security & RLS Guidance: Covers Row Level Security policies, SECURITY DEFINER functions, least-privilege roles, and performance-safe policy patterns. - Use Case: Before writing a migration that adds a column and index to a multi-tenant orders table, load this Skill to get the correct composite index strategy, idempotent constraint syntax, and RLS policy pattern. ## Quick Start Ask the AI to review your Postgres schema or query using the Supabase Postgres best practices before writing any SQL.

Frequently Asked Questions about supabase-postgres-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize slow Postgres queries?

Start with EXPLAIN ANALYZE to find sequential scans and rows removed by filters, then add indexes on WHERE and JOIN columns. The query performance rules cover missing indexes, composite indexes, partial indexes, and covering indexes with measured impact.

How to write RLS policies in Supabase without hurting performance?

Wrap functions like auth.uid() in a SELECT subquery so they execute once instead of per row, and index every column used in policies. For complex checks, use SECURITY DEFINER functions in a private schema with EXECUTE revoked from public roles.

Does Postgres automatically index foreign key columns?

No, Postgres does not index foreign key columns automatically. Missing FK indexes cause slow JOINs and table-scanning CASCADE deletes, so create an index on each referencing column explicitly.

Why do prepared statements fail with connection pooling?

Named prepared statements are tied to individual connections, so transaction-mode poolers like PgBouncer reassign connections and the statement disappears. Use unnamed statements, deallocate after use, or switch to session mode pooling.

When should I use cursor pagination instead of OFFSET?

Use cursor-based pagination whenever users page deeply into large result sets. OFFSET scans all skipped rows and slows linearly, while keyset pagination with a WHERE clause on the last seen ID stays constant time at any depth.