postgres-patterns
From affaan-m
Patrones de base de datos PostgreSQL para optimización de consultas, diseño de esquemas, indexación y seguridad. Basado en las buenas prácticas de Supabase.
Provides a PostgreSQL reference of indexing, data type, RLS, and query patterns with example SQL snippets.
Use it when
- Writing SQL queries or migrations
- Designing database schemas or choosing index types
- Diagnosing slow queries via pg_stat_statements
- Setting up Row Level Security or connection pooling
Skip it if
- Only a static reference/cheatsheet, not an executable tool
- Overlaps with the database-reviewer agent for full review workflows
- Assumes PostgreSQL/Supabase specifically, not other databases
Facts
- Repository
- affaan-m/ECC
- Status
- Actively maintained
- Last commit
- Source file
- .kiro/skills/postgres-patterns/SKILL.md
Source preview
The instructions Claude Code reads when this skill runs.
# Patrones PostgreSQL
Referencia rápida de las buenas prácticas de PostgreSQL. Para orientación detallada, usa el agente `database-reviewer`.
## Cuándo Activar
- Escribir consultas SQL o migraciones
- Diseñar esquemas de base de datos
- Diagnosticar consultas lentas
- Implementar Row Level Security
- Configurar connection pooling
## Referencia Rápida
### Tabla de Índices
| Patrón de Consulta | Tipo de Índice | Ejemplo |
|-------------------|----------------|---------|
| `WHERE col = value` | B-tree (por defecto) | `CREATE INDEX idx ON t (col)` |
| `WHERE col > value` | B-tree | `CREATE INDEX idx ON t (col)` |
| `WHERE a = x AND b > y` | Compuesto | `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)` |
| Rangos de series temporales | BRIN | `CREATE INDEX idx ON t USING brin (col)` |
### Referencia Rápida de Tipos de Datos
| Caso de Uso | Tipo Correcto | Evitar |
|-------------|--------------|--------|
| IDs | `bigint` | `int`, UUID aleatorio |
| Cadenas | `text` | `varchar(255)` |
| Timestamps | `timestamptz` | `timestamp` |
| Dinero | `numeric(10,2)` | `float` |
| Flags | `boolean` | `varchar`, `int` |
### Patrones Comunes
**Orden del Índice Compuesto:**
```sql
-- Columnas de igualdad primero, luego columnas de rango
CREATE INDEX idx ON orders View full source on GitHub →Other skills
django-tdd
★ 229,918Django testing strategies with pytest-django, TDD methodology, factory_boy, mocking, coverage, and testing Django REST Framework APIs.
affaan-mupdated 14d agoMITclickhouse-io
★ 229,918ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.
affaan-mupdated 14d agoMITlaravel-patterns
★ 229,918Patrones de arquitectura Laravel, routing/controladores, Eloquent ORM, capas de servicio, colas, eventos, caché y API resources para aplicaciones en producción.
affaan-mupdated 14d agoMITverification-loop
★ 229,918Sistema de verificación completo para sesiones de Claude Code.
affaan-mupdated 14d agoMITstrategic-compact
★ 229,918Suggests manual context compaction at logical intervals to preserve context through task phases rather than arbitrary auto-compaction.
affaan-mupdated 14d agoMITfrontend-patterns
★ 229,918Patrones de desarrollo frontend para React, Next.js, gestión de estado, optimización de rendimiento y buenas prácticas de UI.
affaan-mupdated 14d agoMIT