supabase-postgres-best-practices

Provides Postgres performance optimization rules for queries, schema design, and connection management.

1|Updated Mar 13, 2026
One-click install
npx skills add https://github.com/dominionism/Noesis --skill supabase-postgres-best-practices-dominionism
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: supabase-postgres-best-practices
Source: https://github.com/dominionism/Noesis/tree/main/assets/skills/supabase-postgres-best-practices
Command: npx skills add https://github.com/dominionism/Noesis --skill supabase-postgres-best-practices-dominionism

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Postgres databases often suffer from slow queries, missing indexes, connection exhaustion, and unsafe schema changes that are hard to diagnose without deep expertise. This Skill gives you a prioritized, rule-based reference so you can write, review, and optimize Postgres SQL correctly the first time. ## Core Features & Use Cases - Prioritized Rule Library: 8 categories of performance rules ranked by impact, from critical query performance and connection management to advanced features like full-text search and JSONB indexing. - Incorrect vs. Correct SQL Examples: Every rule shows the anti-pattern alongside the optimized solution, with EXPLAIN output and impact metrics. - Supabase-Specific Guidance: Covers Row Level Security policies, RLS performance patterns, connection pooling modes, and prepared statement handling in pooled environments. - Use Case: When writing a migration that adds a foreign key, consult the schema rules to add the required index, use idempotent constraint creation, and choose the right primary key strategy. ## Quick Start Ask the AI to review your Postgres query or schema design against the Supabase best practices rules and suggest optimizations.

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

Start by adding indexes on WHERE and JOIN columns, then use EXPLAIN ANALYZE to identify sequential scans and rows removed by filters. The query performance rules cover composite indexes, covering indexes with INCLUDE, and partial indexes for filtered queries.

What is the best way to handle Postgres connection pooling?▼

Use a pooler like PgBouncer between your application and Postgres, sizing the pool at roughly (CPU cores * 2) plus spindle count. Transaction mode works for most apps, but prepared statements require unnamed statements or session mode to avoid conflicts.

Does Postgres automatically index foreign key columns?▼

No, Postgres does not automatically index foreign key columns. Missing FK indexes cause slow JOINs and table-locking CASCADE deletes, so you should create an index on every referencing column and audit for missing ones with a pg_constraint query.

How do I make Row Level Security policies faster in Supabase?▼

Wrap functions like auth.uid() in a SELECT subquery so they execute once instead of per row, which can be over 100x faster on large tables. Also add indexes on columns referenced in policies and use security definer functions for complex checks.

Why does OFFSET pagination get slower on deeper pages?▼

OFFSET scans and discards all skipped rows, so page 10000 scans hundreds of thousands of rows. Cursor-based (keyset) pagination using WHERE id > last_seen_id uses the index directly and stays O(1) regardless of page depth.

When should I partition a Postgres table?▼

Partition when tables exceed roughly 100 million rows, when queries filter by time ranges, or when you need to drop old data efficiently. Range partitioning by date lets queries scan only relevant partitions and makes old-data removal an instant DROP TABLE.