← ClaudeAtlas

postgres-patternslisted

PostgreSQL patterns for query optimization, schema design, indexing, RLS, and connection pooling (Supabase-based). Use this skill whenever writing SQL queries or migrations, designing schemas, choosing indexes, troubleshooting slow queries, or implementing Row Level Security. It is a quick reference — escalate to the database-reviewer agent for in-depth review.
sardonyx0827/dotfiles · ★ 0 · API & Backend · score 72
Install: claude install-skill sardonyx0827/dotfiles
# PostgreSQL Patterns Quick reference for PostgreSQL best practices. For detailed guidance, use the `database-reviewer` agent. ## When to Activate - Writing SQL queries or migrations - Designing database schemas - Troubleshooting slow queries - Implementing Row Level Security - Setting up connection pooling ## Quick Reference ### Index Cheat Sheet | Query Pattern | Index Type | Example | | ----------------------- | ---------------- | ---------------------------------------- | | `WHERE col = value` | B-tree (default) | `CREATE INDEX idx ON t (col)` | | `WHERE col > value` | B-tree | `CREATE INDEX idx ON t (col)` | | `WHERE a = x AND b > y` | Composite | `CREATE INDEX idx ON t (a, b)` | | `WHERE jsonb @> '{}'` | GIN | `CREATE INDEX idx ON t USING gin (col)` | | `WHERE tsv @@ query` | GIN | `CREATE INDEX idx ON t USING gin (col)` | | Time-series ranges | BRIN | `CREATE INDEX idx ON t USING brin (col)` | ### Data Type Quick Reference | Use Case | Correct Type | Avoid | | ---------- | --------------- | ------------------ | | IDs | `bigint` | `int`, random UUID | | Strings | `text` | `varchar(255)` | | Timestamps | `timestamptz` | `timestamp` | | Money | `numeric(10,2)` | `float` | | Flags | `boolean` | `varchar`, `int` | ### Common Pa