affaan-m avatar

Postgres Patterns

A quick reference guide for PostgreSQL best practices pulled from Supabase's patterns. You get index selection rules (B-tree vs GIN vs BRIN), proper data type choices (bigint for IDs, timestamptz over timestamp), and common patterns like cursor pagination and queue processing with SKIP LOCKED. The real value is in the specific examples: composite index column ordering, covering indexes to avoid table lookups, and that RLS policy trick where you wrap auth.uid() in a SELECT. Also includes queries to find unindexed foreign keys and detect table bloat. It's meant as a cheat sheet when writing migrations or troubleshooting slow queries, not a tutorial. For deeper analysis, they point you to a database-reviewer agent.

skills.sh installs
6.3K
GitHub stars
300.3K
last updated
Aug 21, 2026

Install

$ npx -y skills add affaan-m/ecc --skill postgres-patterns --agent claude-code

Installs into .claude/skills of the current project.

Files

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 PatternIndex TypeExample
WHERE col = valueB-tree (default)CREATE INDEX idx ON t (col)
WHERE col > valueB-treeCREATE INDEX idx ON t (col)
WHERE a = x AND b > yCompositeCREATE INDEX idx ON t (a, b)
WHERE jsonb @> '{}'GINCREATE INDEX idx ON t USING gin (col)
WHERE tsv @@ queryGINCREATE INDEX idx ON t USING gin (col)
Time-series rangesBRINCREATE INDEX idx ON t USING brin (col)

Data Type Quick Reference

Use CaseCorrect TypeAvoid
IDsbigintint, random UUID
Stringstextvarchar(255)
Timestampstimestamptztimestamp
Moneynumeric(10,2)float
Flagsbooleanvarchar, int

Common Patterns

Sponsors

Details

Repository
github.com/affaan-m/ecc
Categories
Backend & APIs, Security, Design & UI/UX, Databases
First seen
Jul 14, 2026

More from affaan-m/ecc

All 263
1assistant-ui avatarsetupassistant-ui/skillsInstalls and configures assistant-ui in a project via the CLI, and picks the right runtime for a backend. Use for first-time install, scaffold, or config: `npx 6.3Kskills.sh installs
2jeffallan avatarjava-architectjeffallan/claude-skillsUse when building, configuring, or debugging enterprise Java applications with Spring Boot 3.x, microservices, or reactive programming. Invoke to implement WebF6.2Kskills.sh installs
3affaan-m avatardjango-patternsaffaan-m/eccDjango architecture patterns, REST API design with DRF, ORM best practices, caching, signals, middleware, and production-grade Django apps.6.2Kskills.sh installs
4jeffallan avatarnestjs-expertjeffallan/claude-skillsCreates and configures NestJS modules, controllers, services, DTOs, guards, and interceptors for enterprise-grade TypeScript backend applications. Use when buil6.2Kskills.sh installs
5vercel-labs avatarportlessvercel-labs/portlessSet up and use portless for named local dev server URLs (e.g. https://myapp.localhost instead of http://localhost:3000). Use when integrating portless into a pr6.2Kskills.sh installs
6affaan-m avatarlaravel-patternsaffaan-m/eccLaravel architecture patterns, routing/controllers, Eloquent ORM, service layers, queues, events, caching, and API resources for production apps.6.1Kskills.sh installs