database-indexing
Skill0 starsChanged 5 months agoApache-2.0View on GitHub
Design and review database indexes and query plans — covering
In this repository128 other files it gives its agents.
- AGENTS.mdAGENTS.md
- accessibility-implementationSkill
- accessibility-reviewSkill
- api-changelogSkill
- api-designSkill
- auth-designSkill
- caching-strategiesSkill
- chaos-experiment-designSkill
- ci-cd-pipelinesSkill
- cli-designSkill
- cloudformation-reviewSkill
- codebase-orientationSkill
- code-commentsSkill
- code-reviewSkill
- commit-messagesSkill
- container-reviewSkill
- database-migrationsSkill
- debuggingSkill
- dependency-upgradesSkill
- design-system-contributionSkill
- design-tokensSkill
- desktop-releaseSkill
- error-handlingSkill
- feature-flagsSkill
- finops-reviewSkill
- frontend-performanceSkill
- git-conflict-resolutionSkill
- graphql-schema-designSkill
- helm-chart-scaffoldingSkill
- i18n-reviewSkill
- kubernetes-reviewSkill
- load-test-planningSkill
- logging-observabilitySkill
- message-queue-designSkill
- migration-playbooksSkill
- mobile-releaseSkill
- multi-region-active-activeSkill
- observability-alertsSkill
- openapi-spec-designSkill
- partner-api-integrationSkill
- performance-reviewSkill
- pr-descriptionsSkill
- prompt-injection-hardeningSkill
- pulumi-reviewSkill
- rate-limitingSkill
- refactor-planningSkill
- secrets-managementSkill
- security-reviewSkill
- sql-query-reviewSkill
- terraform-reviewSkill
- test-generationSkill
- threat-modelingSkill
- webhook-designSkill
- websocket-designSkill
- ab-test-analysisSkill
- anomaly-detectionSkill
- cost-anomaly-investigationSkill
- csv-analysisSkill
- data-cleaningSkill
- data-contract-designSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 32
Check existing indexes for redundancy, unused, or wrong column order.
- Distinctive: line 33
Call out write cost, bloat, and CREATE INDEX CONCURRENTLY / ONLINE.
- Very specific: line 65
Never invent table stats or existing indexes.
- Distinctive: line 68
Do not recommend an index that the predicate cannot use (function on the column, leading wildcard, implicit cast).
- Very specific: line 84
Already indexed and still slow: look at selectivity, heap fetches, mis-estimates, and whether the query should be rewritten …
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Database Indexing
Indexes are a write tax you pay to make a specific read cheap. Name the query first. Do not spray indexes on every foreign key "just in case".
For rewriting one statement, use sql-query-review. For schema change
safety, use database-migrations.
Workflow
- Dialect, table size (rows/bytes if known), write rate, and the exact query or EXPLAIN.
- Restate the access path: equality keys, range keys, ORDER BY, and covering columns.
- Propose the smallest index that serves that path (left-prefix, INCLUDE / covering, partial, expression).
- Check existing indexes for redundancy, unused, or wrong column order.
- Call out write cost, bloat, and CREATE INDEX CONCURRENTLY / ONLINE.
- Verification: what EXPLAIN node should disappear, and a rollback
(
DROP INDEX CONCURRENTLY).
Output format
## Indexing plan: <table / query>
**Dialect / size assumption:** …
**Target access path:** …
### Proposed indexes
```sql
-- CREATE INDEX …Why this shape
leading columns, range, covering, partial predicate
Do not add
…
Apply / rollback
CONCURRENTLY, lock notes, DROP
Verify
EXPLAIN expectation
## Rules
1. Never invent table stats or existing indexes. If missing, say what
you assumed or ask for `\d` / `SHOW INDEX` / EXPLAIN.
2. Equality columns before range columns in a B-tree.
3. Do not recommend an index that the predicate cannot use (function
on the column, leading wildcard, implicit cast).
4. One new index per proven query until writes hurt. Composite beats
three overlapping singles.
5. Unique constraints *are* indexes; do not duplicate them.
6. Warehouse engines: talk clustering/partition prune/clustering keys,
not "add a B-tree on user_id", unless the engine has them.
7. `CREATE INDEX` on a large hot table without CONCURRENTLY/ONLINE is
a finding.
## Edge cases
- **ORM-only:** infer the SQL, then index that SQL — not the object
graph.
- **Many slow queries:** rank by frequency × latency; index the top
two, not twenty.
- **Already indexed and still slow:** look at selectivity, heap
fetches, mis-estimates, and whether the query should be rewritten
(`sql-query-review`) instead of another index.
- **JSON / arrays:** expression or GIN only when the predicate matches
the operator class.
---Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

