supabase-postgres-best-practices

Review Supabase Postgres queries and schemas for performance and RLS safety.

1|Updated Mar 18, 2024
One-click install
npx skills add https://github.com/erfianugrah/dotfiles --skill supabase-postgres-best-practices-erfianugrah
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: supabase-postgres-best-practices
Source: https://github.com/erfianugrah/dotfiles/tree/main/.pi/agent/skills/supabase-postgres-best-practices
Command: npx skills add https://github.com/erfianugrah/dotfiles --skill supabase-postgres-best-practices-erfianugrah

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you prevent slow queries, unsafe schema patterns, and scaling failures by applying proven Postgres performance and Supabase-specific best practices.

Core Features & Use Cases

  • Query Performance Tuning: Improve index usage, eliminate expensive patterns (like SELECT * and functions on indexed columns), and use EXPLAIN correctly to close estimate/actual gaps.
  • Connection Management for Supabase: Configure pooling and runtime behavior to avoid connection explosions and Supabase pooler pitfalls.
  • Security & RLS Correctness: Apply RLS patterns that avoid recursive evaluation, enforce safe auth usage, and prevent policy mistakes and data leaks.
  • Use Cases: query review, schema/index design, diagnosing production latency, and hardening Supabase RLS + realtime-trigger behavior.

Quick Start

Use the supabase-postgres-best-practices skill to review your query and schema choices, then generate targeted improvements and corrected SQL patterns for performance and RLS safety.

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 Supabase Postgres queries?

Optimize slow Supabase Postgres queries by enforcing best practices for index selection, eliminating expensive patterns like SELECT *, and using EXPLAIN to close gaps between estimated and actual query plans for targeted performance tuning.

What is the best way to prevent recursive Row-Level Security policies in Postgres?

Preventing recursive Row-Level Security (RLS) policies in Postgres requires applying RLS patterns that avoid recursive evaluation, enforce safe auth usage, and prevent policy mistakes that lead to data leaks. Correct RLS security ensures safe data access without infinite loops.

How do I fix Supavisor connection pooling issues in Supabase?

Fix Supabase connection pooling issues by configuring pooling and runtime behavior to avoid connection explosions and Supavisor pooler pitfalls. Proper connection management for Supabase ensures safe operational patterns under real production constraints.

When do I need specific index access methods for Postgres schema design?

You need specific index access methods for Postgres schema design when optimizing query performance and selecting safe operational patterns. Correct index access method selection satisfies requirements for query-plan-driven optimization under real production constraints.

Does this approach help with Supabase realtime trigger latency?

Yes, this approach helps with Supabase realtime trigger latency by hardening Supabase realtime trigger behavior and selecting safe operational patterns. Diagnosing production latency ensures safer lock and cleanup designs under real constraints.