一键导入
database-index-review
Review a query or schema for missing, redundant, or misused indexes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Review a query or schema for missing, redundant, or misused indexes.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Review code changes and report issues by severity with actionable fixes.
Sharpen a fuzzy intention into one measurable objective string that drives the rest of the work.
Convert a Prompt Flow PRS pipeline submission to run a Microsoft Agent Framework workflow.
Build a Model Context Protocol (MCP) server that lets an LLM call into external tools and resources.
Summarize PDF documents into concise bullet-point digests.
Bump a dependency version across a pnpm workspace and update lockfile.
| slug | database-index-review |
| name | Database Index Review |
| version | 0.1.0 |
| description | Review a query or schema for missing, redundant, or misused indexes. |
| category | dev-tools |
| tags | ["database","index","performance","sql"] |
| inputs | [{"name":"query","type":"string","required":true,"description":"SQL query or schema snippet"},{"name":"dbms","type":"string","required":true,"description":"PostgreSQL, MySQL, etc."}] |
| output | {"format":"markdown","description":"Index recommendations with rationale and trade-offs."} |
| author | badhope |
| license | MIT |
| created | "2026-06-21T00:00:00.000Z" |
| updated | "2026-06-21T00:00:00.000Z" |
Slow query investigation, schema design review, or before adding an index.
Provide the query/schema and the database system.
Index recommendations with rationale, trade-offs, and example DDL.
Review the query/schema for index opportunities.
For each recommendation:
1. Identify the access pattern
2. Recommend an index type (B-tree, partial, covering, composite)
3. Provide example DDL
4. Note trade-offs: write overhead, storage, lock impact
5. Flag redundant or unused indexes if visible
Also warn about common mistakes: indexing low-cardinality columns alone, over-indexing, ignoring sort order.
Output:
## Recommendations
...
## Trade-offs
...
Input:
query: 'SELECT * FROM orders WHERE user_id = ? ORDER BY created_at DESC LIMIT 20'
dbms: PostgreSQL
Output:
## Recommendations
Create a composite index:
```sql
CREATE INDEX idx_orders_user_created ON orders(user_id, created_at DESC);
Write overhead on inserts/updates to orders table; monitor index bloat monthly.
## Footguns
These are the bugs that bite every new user.
Check them before shipping:
- **Indexing low-cardinality columns alone**: Indexing a boolean or status column alone doesn't help queries because cardinality is too low.
- how to detect: query plan shows sequential scan despite index existing
- how to fix: create composite indexes that include high-cardinality columns
- **Over-indexing writes**: Too many indexes slow down inserts, updates, and deletes.
- how to detect: write latency increased after adding indexes
- how to fix: audit indexes quarterly, remove unused or redundant ones
- **Ignoring sort order in index**: Creating index `(a, b)` but querying `ORDER BY a DESC, b DESC` doesn't use the index efficiently.
- how to detect: EXPLAIN shows filesort despite index existing
- how to fix: match index column order and direction to query pattern
- **Partial index on wrong predicate**: Creating a partial index with a predicate that doesn't match actual query filters.
- how to detect: index not used in query plan despite being relevant
- how to fix: verify index predicate matches the most common WHERE clause
- **Not considering covering indexes**: Queries requiring additional columns cause index lookups to become expensive.
- how to detect: query uses index but still takes too long
- how to fix: include frequently accessed columns in the index (covering index)