SU

supabase-load-scale

Strategies for scaling Supabase including connection pooling, read replicas, and database partitioning.

Install

mkdir -p .claude/skills/supabase-load-scale && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/4220" && unzip -o skill.zip -d .claude/skills/supabase-load-scale && rm skill.zip

Installs to .claude/skills/supabase-load-scale

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Use when preparing a Supabase project for production load — traffic spikes, connection-limit tuning, read replicas for analytics queries, CDN caching for Storage, regional Edge Function deployment, or partitioning large tables. Covers read replicas, Supavisor connection pooling, compute-size upgrades, Storage CDN, Edge Function regions, and table partitioning. Trigger with phrases like "supabase scale", "supabase read replica", "supabase connection pooling", "supabase compute upgrade", "supabase CDN storage", "supabase edge function regions", "supabase partitioning", "supavisor", "supabase pool mode".
608 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Configure read replicas for analytics
  • Implement Supavisor connection pooling
  • Partition large database tables
  • Deploy edge functions to specific regions
  • Optimize storage with CDN caching

How it works

It maps scaling requirements to specific infrastructure layers including compute tiers, connection pooling modes, and database partitioning strategies. It provides CLI commands and SQL patterns to implement these changes.

Inputs & outputs

You give it
Traffic metrics and database schema
You get back
Scaling configuration and performance optimization SQL

When to use supabase-load-scale

  • Configure read replicas for analytics
  • Implement connection pooling with Supavisor
  • Partition large database tables
  • Optimize Edge Function regional deployment

About this skill

Supabase Load & Scale

Overview

Supabase scaling operates at six layers: read replicas (offload analytics and reporting queries), connection pooling (Supavisor, the pgBouncer replacement, with transaction/session modes), compute upgrades (vCPU/RAM tiers), CDN for Storage (cache public bucket assets at the edge), Edge Function regions (deploy functions closer to users), and table partitioning (split billion-row tables for query performance). This skill gives the high-level workflow inline and links to references/ for the full createClient config, SQL, and CLI for each layer.

Prerequisites

  • Supabase project on a Pro plan or higher (read replicas require Pro+)
  • @supabase/supabase-js v2+ installed
  • supabase CLI installed and linked to your project
  • Database access via psql or Supabase SQL Editor
  • TypeScript project with generated database types

Instructions

Step 1 — Read Replicas and Connection Pooling

Route read-heavy queries (dashboards, reports, search) to a read replica while keeping writes on the primary. Supavisor pools connections in two modes: transaction (default, port 6543 — shares connections, no prepared statements) and session (port 5432 — one connection per client, needed for prepared statements and LISTEN/NOTIFY). Configure two clients — a primary and a read-only replica pointed at the -ro URL:

// lib/supabase.ts
export const supabase = createClient<Database>(
  process.env.SUPABASE_URL!, process.env.SUPABASE_ANON_KEY!)       // writes + realtime
export const supabaseReadOnly = createClient<Database>(
  process.env.SUPABASE_READ_REPLICA_URL!, process.env.SUPABASE_ANON_KEY!) // analytics

Then send analytics queries to supabaseReadOnly and all writes to supabase. Replicas lag slightly (typically <100ms), so never read-after-write on a replica. Full client config, pooled psql connection strings, query-routing services, and a pool-usage monitoring query: read replicas and connection pooling.

Step 2 — Compute Upgrades, CDN for Storage, and Edge Function Regions

Match compute tier to traffic (Micro 60 connections → 4XL 480), serve public Storage buckets through the CDN with long cacheControl headers plus content-addressed paths for cache busting, and deploy Edge Functions to the region closest to users:

supabase projects update --experimental --compute-size large   # scale compute
supabase functions deploy my-function --region eu-west-1        # deploy near users

Full compute selection table, CDN upload/transform patterns, versioned-asset cache busting, and the regional geo-router Edge Function: compute, CDN, and edge regions.

Step 3 — Database Table Partitioning

Split large append-heavy tables (events, logs, metrics) by date range so queries scan only the relevant partitions and old data drops cheaply. See table partitioning patterns for range partitioning by date, automated partition creation via pg_cron, SDK query patterns with partition-key filters, and partition drop for data retention.

Output

  • Read replica client configured for analytics/dashboard queries, primary for writes
  • Connection pooling mode selected (transaction vs session) with correct port
  • Compute tier matched to traffic requirements
  • Storage uploads optimized with CDN cache headers and image transforms
  • Edge Functions deployed to the region closest to users
  • Large tables partitioned by date range with automated partition management
  • Data retention policy via partition drops

Error Handling

IssueCauseSolution
too many connections for roleExceeded Supavisor pool limitUse transaction mode (port 6543), reduce idle connections, upgrade compute
Read replica returns stale dataReplication lag (typically <100ms)Do not read-after-write on replica; use primary for consistency-critical reads
no partition of relation "events" found for rowInsert date outside any partition rangeCreate a DEFAULT partition or pre-create future partitions
Storage CDN returns old fileCached at edgeUse content-addressed paths (hash.ext) or set shorter cacheControl
Edge Function cold startFirst request to a regionUse keep-alive cron ping or accept ~200ms cold start
prepared statement already existsTransaction mode doesn't support prepared statementsSwitch to session mode (port 5432) or disable prepared statements in your ORM

Examples

Quick Connection Pool Check

# Check how many connections are in use right now
psql "$DATABASE_URL" -c "SELECT count(*) AS active_connections FROM pg_stat_activity WHERE state = 'active';"

For deeper worked examples — swapping an existing table to a partitioned one (create/migrate/rename in a transaction) and measuring live read-replica lag — see advanced scaling examples.

Resources

Next Steps

For reliability patterns (circuit breakers, offline queues, graceful degradation), see supabase-reliability-patterns.

When not to use it

  • Read-after-write operations on read replicas
  • Prepared statements in transaction mode

Prerequisites

Supabase project on Pro plan or higher@supabase/supabase-js v2+Supabase CLI installedDatabase access via psql

Limitations

  • Read replicas typically have <100ms lag
  • Transaction mode does not support prepared statements

How it compares

This approach focuses on specific Supabase-native scaling primitives like Supavisor and read-replica routing rather than general database tuning.

Compared to similar skills

supabase-load-scale side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
supabase-load-scale (this skill)127dCautionAdvanced
sql-optimization-patterns642moNo flagsAdvanced
supabase-postgres-best-practices46moNo flagsIntermediate
supabase-performance-tuning427dReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

More by jeremylongshore

View all by jeremylongshore

analyzing-logs

jeremylongshore

Analyze application logs to detect performance issues, identify error patterns, and improve stability by extracting key insights.

14123

ollama-setup

jeremylongshore

Configure auto-configure Ollama when user needs local LLM deployment, free AI alternatives, or wants to eliminate hosted API costs. Trigger phrases: "install ollama", "local AI", "free LLM", "self-hosted AI", "replace OpenAI", "no API costs". Use when appropriate context detected. Trigger with relevant phrases based on skill purpose.

1167

backtesting-trading-strategies

jeremylongshore

Backtest crypto and traditional trading strategies against historical data. Calculates performance metrics (Sharpe, Sortino, max drawdown), generates equity curves, and optimizes strategy parameters. Use when user wants to test a trading strategy, validate signals, or compare approaches. Trigger with phrases like "backtest strategy", "test trading strategy", "historical performance", "simulate trades", "optimize parameters", or "validate signals".

1071

generating-database-seed-data

jeremylongshore

Process this skill enables AI assistant to generate realistic test data and database seed scripts for development and testing environments. it uses faker libraries to create realistic data, maintains relational integrity, and allows configurable data volumes. u... Use when working with databases or data models. Trigger with phrases like 'database', 'query', or 'schema'.

1033

cursor-codebase-indexing

jeremylongshore

Execute set up and optimize Cursor codebase indexing. Triggers on "cursor index setup", "codebase indexing", "index codebase", "cursor semantic search". Use when working with cursor codebase indexing functionality. Trigger with phrases like "cursor codebase indexing", "cursor indexing", "cursor".

885

testing-mobile-apps

jeremylongshore

Execute mobile app testing on iOS and Android devices/simulators. Use when performing specialized testing. Trigger with phrases like "test mobile app", "run iOS tests", or "validate Android functionality".

810

You might also like

sql-optimization-patterns

wshobson

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

64220

supabase-postgres-best-practices

davila7

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

439

supabase-performance-tuning

jeremylongshore

Optimize Supabase API performance with caching, batching, and connection pooling. Use when experiencing slow API responses, implementing caching strategies, or optimizing request throughput for Supabase integrations. Trigger with phrases like "supabase performance", "optimize supabase", "supabase latency", "supabase caching", "supabase slow", "supabase batch".

416

aws-aurora

alinaqi

AWS Aurora Serverless v2, RDS Proxy, Data API, connection pooling

110

analyzing-query-performance

jeremylongshore

Execute use when you need to work with query optimization. This skill provides query performance analysis with comprehensive guidance and automation. Trigger with phrases like "optimize queries", "analyze performance", or "improve query speed".

18

find-hypertable-candidates

timescale

Use this skill to analyze an existing PostgreSQL database and identify which tables should be converted to Timescale/TimescaleDB hypertables. **Trigger when user asks to:** - Analyze database tables for hypertable conversion potential - Identify time-series or event tables in an existing schema - Evaluate if a table would benefit from Timescale/TimescaleDB - Audit PostgreSQL tables for migration to Timescale/TimescaleDB/TigerData - Score or rank tables for hypertable candidacy **Keywords:** hypertable candidate, table analysis, migration assessment, Timescale, TimescaleDB, time-series detection, insert-heavy tables, event logs, audit tables Provides SQL queries to analyze table statistics, index patterns, and query patterns. Includes scoring criteria (8+ points = good candidate) and pattern recognition for IoT, events, transactions, and sequential data.

18

Search skills

Search the agent skills registry