Skip to content
cccskills
FreePublished on GitHub

database-indexing

PostgreSQL indexing: B-tree, GIN, GiST, composite, partial, covering, CONCURRENTLY, bloat detection.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3 stars(GitHub 3 + cccskills 0)
Works withPostgreSQL

Run score Not tested

See how to install

Files included (4)

  • SKILL.md3.5 KB
  • references/anti-patterns.md651 B
  • references/checklists.md825 B
  • references/index-types.md986 B

SKILL.md (original)

Review the instructions the agent will receive before you install.

Database Indexing (PostgreSQL)

Diseñar, crear y mantener índices en Postgres 15+ en contexto multi-tenant Educabot.

Cuándo usar / NO usar

UsarNO usar
Queries lentas con Seq Scan en tablas grandesTablas <10k rows (Seq Scan suele ganar)
Schema nuevo: planificar índicesBooleans/enums baja cardinalidad (usar partial)
Revisión periódica: faltantes/no usadosAlta write, pocas reads
Bloat, REINDEX necesarioFull-text search → /search-setup
Multi-tenant: tenant_id primera columna compositeQuery puntual lenta → /query-optimization

Tipos de índices

B-tree (default, 95% de casos), GIN (arrays/jsonb/tsvector), GiST (geo/ranges), BRIN (tablas enormes ordenadas), Partial (filtro en definición), Covering/INCLUDE, Expression.

→ Read references/index-types.md for detailed type comparison table and JSONB indexing guide

Cuándo crear

  • WHERE con alta selectividad (>100 rows devueltos dilute beneficio)
  • JOIN (especialmente FKs)
  • ORDER BY / GROUP BY frecuentes
  • Constraints UNIQUE
  • Regla: query frecuente que escanea miles para devolver pocos → indexar

Composite indexes

Un índice (a, b, c) sirve para a, a,b, a,b,c — NO para b, c, o b,c solos (leftmost prefix).

Orden de columnas: igualdad primero (tenant_id =) → rango después (created_at >) → ORDER BY al final.

CONCURRENTLY en producción

Obligatorio en tablas grandes: no bloquea writes. No puede correr dentro de transacción — separar en su propia migration. Si falla queda índice INVALID → detectar con pg_index WHERE NOT indisvalid → DROP INDEX CONCURRENTLY.

Detectar faltantes

Consultar pg_stat_user_tables donde seq_scan > idx_scan AND n_live_tup > 10000. Luego revisar queries reales con pg_stat_statements.

Detectar no usados

Consultar pg_stat_user_indexes donde idx_scan = 0 tras 1 mes de observación. DROP INDEX CONCURRENTLY. Excepción: índices únicos que respaldan constraints.

Foreign keys

Postgres no crea índice automático en columnas FK. Sin índice cada DELETE/UPDATE en parent hace seq scan de child. Siempre crear índice en child FK.

EXPLAIN post-creación

Verificar con EXPLAIN (ANALYZE, BUFFERS). Planes esperables: Index Scan, Index Only Scan (ideal), Bitmap Heap Scan. Si Seq Scan → índice no se usa. Ver /query-optimization.

Bloat y REINDEX

B-tree se bloatea con updates/deletes. Monitorear con pgstattuple. Reparar: REINDEX INDEX CONCURRENTLY o pg_repack. Agendar trimestral para índices calientes.

Multi-tenant Educabot

Todo índice compuesto debe empezar por tenant_id para que RLS y queries filtradas lo aprovechen. Patrón: (tenant_id, student_id, period_id).

Anti-patterns

→ Read references/anti-patterns.md for 12 common indexing anti-patterns

Checklist

→ Read references/checklists.md for pre-creation checklist (11 items) and periodic maintenance checklist (5 items)

Delegación

  • /query-optimization — análisis de query lenta puntual
  • /search-setup — full-text search (tsvector, GIN)
  • /data-migrations — migraciones sin downtime, separación CONCURRENTLY
  • /db-diagram — diagramar schema

Reviews

No reviews yet. Tell others what you thought.

Comments

No login needed. Share how it worked for you, ask a question, or note where it did not run.

No comments yet. Be the first to write one.

Comments are published right away. Do not include personal information such as email addresses or phone numbers. Up to 2 URLs.

0 / 1,000 characters

This form is protected by reCAPTCHA, and the Google Privacy Policy and Terms of Service apply.

More skills from this repository

Plan, design, and implement A/B tests and experiments with statistical rigor. Covers hypothesis frameworks, sample sizing, metrics, and result analysis.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Web/mobile accessibility decision guide: WCAG 2.2 AA, ARIA, keyboard nav, focus management, contrast, testing. Use for: a11y, accessibility, wcag, aria, screen reader, keyboard, contrast.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Generate, iterate, and scale ad creative for paid advertising across Google, Meta, LinkedIn, and X. Covers platform specs, creative frameworks, and quality validation.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Musica interactiva para juegos: layering vertical, re-secuenciacion horizontal, stingers, reglas de transicion con sync points, y mapeo de estados de gameplay a musica. Usar para: musica adaptativa, sistema de musica dinamica, transiciones musicales, combat music.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Design multi-agent systems, create agent architectures, define communication patterns, and build autonomous agent workflows with structured evaluation frameworks.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

Inter-agent communication protocol for C-suite agent teams. Defines invocation syntax, loop prevention, isolation rules, response formats, and quality loops.

The English summary is being prepared. Showing the original description.

SebastianLuser/claude-code-arcane3Updated Oct 27, 2026

See all skills by SebastianLuser

Report a problem with this skill