postgres-patterns
Installation
SKILL.md
PostgreSQL Patterns
Postgres reference oriented toward Supabase practice.
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 (correlated insert order) | BRIN | CREATE INDEX idx ON t USING brin (col) |
On live tables, use CREATE INDEX CONCURRENTLY. Plain CREATE INDEX blocks writes. CONCURRENTLY cannot run inside a transaction block; a failed build leaves an INVALID index to drop and retry.