supabase-postgres-best-practices

Provide prioritized Postgres performance and Supabase RLS best practices with incorrect versus correct SQL patterns.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It helps developers prevent slow queries, inefficient schemas, unstable performance, and security issues in Postgres—especially when building with Supabase—by enforcing practical, example-driven performance and correctness rules.

Core Features & Use Cases

  • Postgres performance rule set across query, connections, RLS, schema, locking, and more: apply prioritized guidance with concrete “incorrect vs correct” SQL patterns to improve real workloads.
  • Indexing and query-shape optimization: address missing, composite, covering, partial, and correct index types using precise SQL rewrites and examples.
  • Operational and safety guidance for production: cover connection pooling, idle timeouts, prepared statements with pooling, vacuum/analyze, and deadlock/lock contention practices.
  • RLS correctness and performance: build tenant-safe policies with patterns that avoid per-row expensive calls and support indexing.
  • Use cases: query review and refactoring, migration/schema design support, performance diagnosis via EXPLAIN/ANALYZE, and RLS policy hardening for multi-tenant apps.

Quick Start

Ask an AI to “Use supabase-postgres-best-practices to review this query and propose the highest-impact fixes with incorrect vs correct SQL examples and the expected performance impact.”

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 optimize slow Postgres queries in Supabase, you should run EXPLAIN ANALYZE to diagnose bottlenecks and apply indexing, query-shape rewrites, and connection pooling rules. This skill provides concrete incorrect versus correct SQL patterns to refactor queries for maximum performance impact.

What are the best practices for Supabase RLS policies?

Supabase RLS best practices involve building tenant-safe policies that avoid expensive per-row function calls and ensuring proper indexing. This skill provides correct SQL patterns to harden multi-tenant RLS policies without degrading query performance.

How do I fix connection pooling issues in Postgres?

Fix Postgres connection pooling issues by configuring idle timeouts, managing prepared statements correctly with poolers, and applying operational safety rules. This skill outlines connection-management practices to stabilize production workloads and prevent pool exhaustion.

When should I use composite or partial indexes in Postgres?

Use composite, partial, or covering indexes in Postgres when query shapes involve multiple columns, conditional filters, or require index-only scans. This skill helps identify missing indexes and provides precise SQL rewrites to select the correct index type for your workload.

How do I write migration-safe DDL for production Postgres?

Write migration-safe DDL for production Postgres by following schema best practices that minimize lock contention and prevent downtime. This skill provides operational guidance on vacuum, analyze, and locking practices to ensure smooth schema changes in Supabase-backed systems.