supabase-postgres-best-practices

Analyze SQL and EXPLAIN plans to optimize Supabase Postgres queries and schemas.

Updated Apr 20, 2025
One-click install
npx skills add https://github.com/cathayrisk/Anya --skill supabase-postgres-best-practices-cathayrisk
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: supabase-postgres-best-practices
Source: https://github.com/cathayrisk/Anya/tree/main/skills/supabase-postgres-best-practices
Command: npx skills add https://github.com/cathayrisk/Anya --skill supabase-postgres-best-practices-cathayrisk

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers and DBAs identify and fix Postgres performance issues, including slow queries, missing or suboptimal indexes, inefficient schema patterns, and misconfigured connection management on Supabase-hosted Postgres instances.

Core Features & Use Cases

  • Query performance guidance: Explain slow queries, interpret EXPLAIN output, and recommend rewrites and indexes.
  • Schema and indexing advice: Recommend schema changes, partial and composite indexes, and best practices to reduce bloat and improve access patterns.
  • Operational and security notes: Provide connection pooling, concurrency, RLS, and monitoring recommendations tailored to Supabase environments.
  • Use Case: Review a slow dashboard query, generate corrected SQL with index suggestions, and estimate expected performance impact.

Quick Start

Analyze this SQL query and schema for missing indexes, inefficient joins, and provide optimized SQL, suggested indexes, and connection pooling recommendations tailored for Supabase Postgres.

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 on Supabase?

To fix slow Postgres queries on Supabase, analyze your SQL with EXPLAIN plans to identify bottlenecks, then apply suggested index rewrites and connection pooling configurations. This reduces query latency and improves dashboard load times.

What is the best way to design indexes for Supabase Postgres schemas?

The best way to design indexes for Supabase Postgres is to implement partial and composite indexes based on your specific access patterns. Proper schema design and indexing reduce table bloat and significantly improve data retrieval speeds.

How does row-level security affect Supabase database performance?

Row-level security (RLS) policies can degrade Supabase database performance if not properly optimized. Analyzing RLS configurations alongside query plans helps identify policy bottlenecks and ensures secure data access without sacrificing query speed.

Can I use connection pooling to improve Supabase Postgres concurrency?

Yes, you can configure connection pooling to improve Supabase Postgres concurrency. Proper connection management prevents connection exhaustion during traffic spikes and allows the database to handle simultaneous requests efficiently.

Why does my Supabase Postgres query ignore the indexes I created?

Your Supabase Postgres query might ignore indexes due to inefficient schema patterns, outdated statistics, or suboptimal query structures. Reviewing the EXPLAIN plan reveals sequential scans and highlights necessary query rewrites or index adjustments.