Skill

Optimize Postgres Queries with Supabase Best Practices

An 8-category, priority-ranked Postgres performance and best-practices reference maintained by Supabase, from query indexes to advanced features.

Works with postgressupabase

78
Spark score
out of 100
Updated 23 days ago
Version 0.1.5

Add to Favorites

Why it matters

Apply Supabase-maintained performance optimization rules to write, review, and optimize Postgres queries, schema designs, and database configurations across 8 critical categories including query performance, connection management, security, and RLS.

Outcomes

What it gets done

01

Review SQL queries and schemas against prioritized performance rules

02

Identify missing or inefficient indexes and suggest optimizations

03

Validate Row-Level Security (RLS) implementations and connection pooling

04

Generate optimized query patterns with correct SQL examples

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/ag-supabase-postgres-best-practices | bash

Overview

Supabase Postgres Best Practices

This skill is an 8-category, priority-ranked Postgres performance and best-practices reference maintained by Supabase, with per-rule files giving incorrect-vs-correct SQL examples and Supabase-specific notes. Use it when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations on Supabase.

What it does

A comprehensive Postgres performance optimization guide maintained by Supabase, organized into 8 rule categories ranked by impact priority: Query Performance (critical, query- prefix), Connection Management (critical, conn-), Security & RLS (critical, security-), Schema Design (high, schema-), Concurrency & Locking (medium-high, lock-), Data Access Patterns (medium, data-), Monitoring & Diagnostics (low-medium, monitor-), and Advanced Features (low, advanced-). Each individual rule lives in its own reference file (e.g. references/query-missing-indexes.md, references/query-partial-indexes.md) containing a brief explanation of why the rule matters, an incorrect SQL example with explanation, a correct SQL example with explanation, optional EXPLAIN output or metrics, and Supabase-specific notes where applicable - plus additional context and references pointing to the underlying Postgres or Supabase documentation for the topic, so a rule can be verified against upstream sources rather than taken on faith.

When to use - and when NOT to

Apply it specifically when writing SQL queries or designing schemas, implementing indexes or query optimization, reviewing a database performance issue, configuring connection pooling or scaling, optimizing for Postgres-specific features, or working with Row-Level Security - these are the six situations the guide itself calls out as the right moments to consult it, rather than a general-purpose database how-to.

Inputs and outputs

Input is a Postgres query, schema design, or performance issue to review. Output is the relevant category's rule file(s) - each with an incorrect-vs-correct SQL comparison and Supabase-specific context - applied to guide the fix.

Integrations

References official Postgres documentation, the PostgreSQL Wiki's performance optimization guide, and Supabase's own database and Row-Level Security documentation.

Who it's for

Developers writing or reviewing Postgres queries and schemas on Supabase who want a priority-ranked, example-backed reference for performance and security best practices - the priority ranking itself doubling as a triage order when time is limited and only the highest-impact categories can be addressed first - rather than relying on general Postgres knowledge alone.

Source README

Supabase Postgres Best Practices

When to Use

Use this skill when you need postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.

Comprehensive performance optimization guide for Postgres, maintained by Supabase. Contains rules across 8 categories, prioritized by impact to guide automated query optimization and schema design.

When to Apply

Reference these guidelines when:

  • Writing SQL queries or designing schemas
  • Implementing indexes or query optimization
  • Reviewing database performance issues
  • Configuring connection pooling or scaling
  • Optimizing for Postgres-specific features
  • Working with Row-Level Security (RLS)

Rule Categories by Priority

Priority Category Impact Prefix
1 Query Performance CRITICAL query-
2 Connection Management CRITICAL conn-
3 Security & RLS CRITICAL security-
4 Schema Design HIGH schema-
5 Concurrency & Locking MEDIUM-HIGH lock-
6 Data Access Patterns MEDIUM data-
7 Monitoring & Diagnostics LOW-MEDIUM monitor-
8 Advanced Features LOW advanced-

How to Use

Read individual rule files for detailed explanations and SQL examples:

references/query-missing-indexes.md
references/query-partial-indexes.md
references/_sections.md

Each rule file contains:

  • Brief explanation of why it matters
  • Incorrect SQL example with explanation
  • Correct SQL example with explanation
  • Optional EXPLAIN output or metrics
  • Additional context and references
  • Supabase-specific notes (when applicable)

References

Limitations

  • Use this skill only when the task clearly matches its upstream product or API scope.
  • Verify commands, API behavior, pricing, quotas, credentials, and deployment effects against current official documentation before making changes.
  • Do not treat generated examples as a substitute for environment-specific tests, security review, or user approval for destructive or costly actions.

FAQ

Common questions

Discussion

Questions & comments ยท 0

Sign In Sign in to leave a comment.