- Added: api-patterns, app-builder, architecture, bash-linux, behavioral-modes, clean-code, code-review-checklist, database-design, deployment-procedures, docker-expert, documentation-templates, game-development, geo-fundamentals, i18n-localization, lint-and-validate, mobile-design, nestjs-expert, nextjs-best-practices, nodejs-best-practices, parallel-agents, performance-profiling, plan-writing, powershell-windows, prisma-expert, python-patterns, react-patterns, red-team-tactics, seo-fundamentals, server-management, tailwind-patterns, tdd-workflow, typescript-expert, vulnerability-scanner - Updated README: skill count 179 → 223 - Added credit for vudovn/antigravity-kit (MIT License) Source: https://github.com/vudovn/antigravity-kit
40 lines
892 B
Markdown
40 lines
892 B
Markdown
# Indexing Principles
|
|
|
|
> When and how to create indexes effectively.
|
|
|
|
## When to Create Indexes
|
|
|
|
```
|
|
Index these:
|
|
├── Columns in WHERE clauses
|
|
├── Columns in JOIN conditions
|
|
├── Columns in ORDER BY
|
|
├── Foreign key columns
|
|
└── Unique constraints
|
|
|
|
Don't over-index:
|
|
├── Write-heavy tables (slower inserts)
|
|
├── Low-cardinality columns
|
|
├── Columns rarely queried
|
|
```
|
|
|
|
## Index Type Selection
|
|
|
|
| Type | Use For |
|
|
|------|---------|
|
|
| **B-tree** | General purpose, equality & range |
|
|
| **Hash** | Equality only, faster |
|
|
| **GIN** | JSONB, arrays, full-text |
|
|
| **GiST** | Geometric, range types |
|
|
| **HNSW/IVFFlat** | Vector similarity (pgvector) |
|
|
|
|
## Composite Index Principles
|
|
|
|
```
|
|
Order matters for composite indexes:
|
|
├── Equality columns first
|
|
├── Range columns last
|
|
├── Most selective first
|
|
└── Match query pattern
|
|
```
|