All skills
Skillintermediate
add index
Add database indexes to improve query performance with migration safety.
Claude Code Knowledge Pack7/10/2026
Overview
Add database indexes to improve query performance with migration safety.
Steps
- Identify the query patterns that need indexing:
- Choose the index type:
- Design the index:
- Create the migration:
- Estimate the impact:
- Deploy safely:
Format
Table: <table name>
Index: <index name>
Columns: <column list>
Type: <B-tree|Hash|GIN|GiST>
Rules
- Always use CONCURRENTLY for production index creation.
- Name indexes descriptively: idx_table_column1_column2.
- Do not create redundant indexes (check existing indexes first).