supabase-postgres-best-practices

Optimize Supabase and PostgreSQL queries with SQL rewrites and index recommendations.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/mmahalwy/cooper --skill supabase-postgres-best-practices-mmahalwy
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: supabase-postgres-best-practices
Source: https://github.com/mmahalwy/cooper/tree/main/.agents/skills/supabase-postgres-best-practices
Command: npx skills add https://github.com/mmahalwy/cooper --skill supabase-postgres-best-practices-mmahalwy

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

A comprehensive rulebook and reference library to diagnose and fix Postgres performance, scaling, and security issues, with Supabase-focused notes to guide practical implementation.

Core Features & Use Cases

  • Query Performance: Identify missing or misused indexes, choose correct index types, and craft covering or composite indexes to eliminate sequential scans.
  • Connection & Concurrency: Recommend connection pooling, idle timeouts, and connection limits to prevent exhaustion and reduce memory pressure.
  • Schema & Data Patterns: Advise on data types, partitioning, primary keys, foreign key indexing, and safe migration patterns to improve long-term maintainability.
  • Security & RLS: Provide patterns for Row-Level Security that balance safety with performance and show how to optimize RLS policies.
  • Monitoring & Diagnostics: Guide use of EXPLAIN ANALYZE, pg_stat_statements, and autovacuum tuning to surface and validate fixes.

Quick Start

Use the supabase-postgres-best-practices skill to analyze a slow query and return prioritized SQL fixes, index recommendations, and configuration changes.

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 in Supabase?▼

To fix slow Postgres queries, analyze execution plans using EXPLAIN ANALYZE to identify sequential scans, then implement composite or covering indexes and rewrite SQL. This process yields concrete SQL fixes and index designs to eliminate slow queries.

How does connection pooling prevent database connection exhaustion in Postgres?▼

Connection pooling prevents exhaustion by limiting concurrent database connections and reusing existing ones, which reduces memory pressure. Configuring idle timeouts and connection limits ensures your Postgres database handles high concurrency without crashing.

How do I optimize Row-Level Security policies for performance in Supabase?▼

Optimizing Row-Level Security (RLS) involves restructuring policies to balance safety with performance by ensuring they leverage indexes effectively. This provides patterns that prevent RLS policies from causing slow query execution times.

Can I use partitioning to improve PostgreSQL scalability and storage?▼

Yes, you can use partitioning to improve PostgreSQL scalability by dividing large tables into smaller, manageable pieces, which accelerates query performance and optimizes storage. This yields schema and data patterns for long-term maintainability.

What is the best way to monitor Postgres performance during production incidents?▼

The best way to monitor Postgres performance during incidents is using pg_stat_statements to surface query bottlenecks and tuning autovacuum settings. This diagnostic approach validates fixes and ensures database reliability under load.

How do I ensure safe migration patterns for schema changes in Postgres?▼

Ensuring safe schema migrations requires applying migration-safe patterns that prevent locking issues during data type changes or index additions. This approach advises on foreign key indexing and structural changes to maintain long-term schema maintainability.