supabase-postgres-best-practices

Optimize Postgres queries, schemas, and connection settings with prioritized SQL fixes.

2|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/hamzaPixl/pixl-ai --skill supabase-postgres-best-practices-hamzapixl
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: supabase-postgres-best-practices
Source: https://github.com/hamzaPixl/pixl-ai/tree/main/packages/crew/skills/supabase-postgres-best-practices
Command: npx skills add https://github.com/hamzaPixl/pixl-ai --skill supabase-postgres-best-practices-hamzapixl

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Postgres databases suffer from slow queries, inefficient schemas, connection exhaustion, and insecure or slow RLS policies; this skill delivers prioritized, actionable best-practice rules and concrete SQL rewrites to diagnose and fix those problems quickly.

Core Features & Use Cases

  • Organized Reference Rules: Eight prioritized categories (query, conn, security, schema, lock, data, monitor, advanced) with focused guidance and examples.
  • Actionable SQL Fixes: Concrete incorrect/correct examples for missing/partial/composite/covering indexes, JSONB and full-text indexing, partitioning, UPSERT patterns, and efficient pagination.
  • Operational Guidance: Connection pooling, connection limits, prepared-statement patterns for pooled environments, transaction best practices, advisory locks, SKIP LOCKED queue processing, and monitoring with EXPLAIN ANALYZE and pg_stat_statements.
  • Use Case: Audit a slow reporting query, receive index and schema-change recommendations, and produce migration-safe commands with impact estimates and monitoring steps.

Quick Start

Analyze this SQL and recommend prioritized index, schema, and RLS changes with example corrected SQL and estimated 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 PostgreSQL queries and fix missing indexes?

To optimize slow PostgreSQL queries, analyze SQL with EXPLAIN ANALYZE and apply composite or covering indexes. This skill provides concrete incorrect versus correct SQL rewrites and prioritized index recommendations to eliminate inefficient query execution.

What is the best way to configure connection pooling for Postgres without breaking prepared statements?

Configuring connection pooling for Postgres requires managing connection limits and using prepared-statement patterns safe for pooled environments. This skill delivers operational guidance to prevent connection exhaustion while maintaining transaction and lock management efficiency.

How do I write RLS policies in PostgreSQL that prevent data leaks without degrading performance?

Writing secure RLS policies in PostgreSQL involves applying RLS-safe policy patterns that prevent data leaks while maintaining query speed. This skill provides actionable schema design and security rules to diagnose and fix insecure or slow Row Level Security configurations.

How do I add migration-safe constraints and partitions to an existing PostgreSQL schema?

Adding migration-safe constraints and partitions to a PostgreSQL schema requires generating safe ALTER commands and applying efficient data-type recommendations. This skill produces migration-safe commands with impact estimates for schema changes across OLTP and analytics workloads.

How do I monitor PostgreSQL performance using pg_stat_statements?

Monitoring PostgreSQL performance with pg_stat_statements involves running prioritized monitoring queries to identify resource bottlenecks. This skill provides operational guidance to track query performance impact, analyze locks, and manage queue processing using SKIP LOCKED.