postgres-patterns
PostgreSQL database patterns for query optimization, schema design, indexing, and security.
Skill by myths-labs
Chalk Labs
Need help deploying postgres-patterns?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/myths-labs-postgres-patterns
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: design, backend, security
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill name
postgres-patterns- Description
- PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.
- License
- MIT
- Instructions
- 143 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# 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 Patterns
**Composite Index Order:**
```sql
-- Equality columns first, then range columns
CREATE INDEX idx ON orders (status, created_at);
-- Works for: WHERE status = 'pending' AND created_at > '2024-01-01'
```
**Covering Index:**
```sql
CREATE INDEX idx ON users (email) INCLUDE (name, created_at);
-- Avoids table lookup for SELECT email, name, created_at
```
**Partial Index:**
```sql
CREATE INDEX idx ON users (email) WHERE deleted_at IS NULL;
-- Smaller index, only includes active users
```
**RLS Policy (Optimized):**
```sql
CREATE POLICY policy ON orders
USING ((SELECT auth.uid()) = user_id); -- Wrap in SELECT!
```
**UPSERT:**
```sql
INSERT INTO settings (user_id, key, value)
VALUES (123, 'theme', 'dark')
ON CONFLICT (user_id, key)
DO UPDATE SET value = EXCLUDED.value;
```
**Cursor Pagination:**
```sql
SELECT * FROM products WHERE id > $last_id ORDER BY id LIMIT 20;
-- O(1) vs OFFSET which is O(n)
```
**Queue Processing:**
```sql
UPDATE jobs SET status = 'processing'
WHERE id = (
SELECT id FROM jobs WHERE status = 'pending'
ORDER BY created_at LIMIT 1
FOR UPDATE SKIP LOCKED
) RETURNING *;
```
### Anti-Pattern Detection
```sql
-- Find unindexed foreign keys
SELECT conrelid::regclass, a.attname
FROM pg_constraint c
JOIN pg_attribute a ON a.attrelid = c.conrelid AND a.attnum = ANY(c.conkey)
WHERE c.contype = 'f'
AND NOT EXISTS (
SELECT 1 FROM pg_index i
WHERE i.indrelid = c.conrelid AND a.attnum = ANY(i.indkey)
);
-- Find slow queries
SELECT query, mean_exec_time, calls
FROM pg_stat_statements
WHERE mean_exec_time > 100
ORDER BY mean_exec_time DESC;
-- Check table bloat
SELECT relname, n_dead_tup, last_vacuum
FROM pg_stat_user_tables
WHERE n_dead_tup > 1000
ORDER BY n_dead_tup DESC;
```
### Configuration Template
```sql
-- Connection limits (adjust for RAM)
ALTER SYSTEM SET max_connections = 100;
ALTER SYSTEM SET work_mem = '8MB';From myths-labs/muse, MIT.
More from myths-labs/muse
- 0.659score
growth-distribution
myths-labs
Cross-platform content distribution and growth strategy for DYA app across 10+ platforms (Xiaohongshu, Douyin, TikTok, Instagram Reels, X/Twitter, Reddit…
SkillAFreshness: A★ 36Claude Code +9 - 0.659score
github-pr-review
myths-labs
Handles PR review comments and feedback resolution.
SkillAFreshness: A★ 36Claude Code +9 - 0.659score
muse-orchestration
myths-labs
Run several long-lived AI coding sessions ("lanes") as one team led by an orchestrator lane.
SkillAFreshness: A★ 36Claude Code +9 - 0.656score
muse-commands
myths-labs
Run MUSE /resume, /save and /bye for continuous work in Codex or Claude Code, preserving the selected role, Lane, decisions and source evidence across sessions.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
markitdown
myths-labs
A Python utility for converting various file formats (PDF, Word, Excel, PowerPoint, etc.) to Markdown.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
coordinator-mode
myths-labs
Multi-agent coordination SOP derived from Anthropic's internal coordinator architecture.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
semantic-search
myths-labs
Zero-dependency TF-IDF search across MUSE memory, roles, and skills.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
javascript-typescript
myths-labs
JavaScript and TypeScript development with ES6+, Node.js, React, and modern web frameworks.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
architect-agent
myths-labs
Software architecture specialist for system design, scalability, and technical decision-making.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
database-reviewer
myths-labs
PostgreSQL database specialist for query optimization, schema design, security, and performance.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
context-health-check
myths-labs
Check actual session context observations; save and reassess after compaction without forcing Bye or guessing model limits.
SkillAFreshness: A★ 36Claude Code +9 - 0.651score
strategic-compact
myths-labs
Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.
SkillAFreshness: A★ 36Claude Code +9
Signals
- Stars
- 36
- Forks
- 4
- Open issues
- 0
- Last commit (this folder)
- Mar 12, 2026 (7 months ago)
- Last release
- Oct 24, 2026 (6 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/myths-labs/muse
- Website
- github.com/myths-labs/muse
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
- 0.406score
postgres-patterns
vibeeval
PostgreSQL database patterns for query optimization, schema design, indexing, and security.
SkillDFreshness: D★ 540Claude Code +9 - 0.299score
postgres-patterns
marshall0524
PostgreSQL database patterns for query optimization, schema design, indexing, and security.
SkillDFreshness: D★ 41Claude Code +9 - 0.294score
postgres-patterns
Luohaothu
PostgreSQL database patterns for query optimization, schema design, indexing, and security.
SkillDFreshness: D★ 26Claude Code +9
More from myths-labs
- 0.659score
github-pr-review
myths-labs
Handles PR review comments and feedback resolution.
SkillAFreshness: A★ 36Claude Code +9 - 0.659score
muse-orchestration
myths-labs
Run several long-lived AI coding sessions ("lanes") as one team led by an orchestrator lane.
SkillAFreshness: A★ 36Claude Code +9 - 0.659score
growth-distribution
myths-labs
Cross-platform content distribution and growth strategy for DYA app across 10+ platforms (Xiaohongshu, Douyin, TikTok, Instagram Reels, X/Twitter, Reddit…
SkillAFreshness: A★ 36Claude Code +9 - 0.656score
muse-commands
myths-labs
Run MUSE /resume, /save and /bye for continuous work in Codex or Claude Code, preserving the selected role, Lane, decisions and source evidence across sessions.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
coordinator-mode
myths-labs
Multi-agent coordination SOP derived from Anthropic's internal coordinator architecture.
SkillAFreshness: A★ 36Claude Code +9 - 0.654score
semantic-search
myths-labs
Zero-dependency TF-IDF search across MUSE memory, roles, and skills.
SkillAFreshness: A★ 36Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get postgres-patterns running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
postgres-patterns skill. Agent Mart. https://agentmart.dev/skills/myths-labs-postgres-patterns (last updated 2026-10-24)