Ask Claude to Suggest Database Indexes Based on Your Query Patterns
Missing indexes are the most common cause of slow database queries, and redundant indexes silently slow down every write. Claude reads your actual query patterns and suggests exactly which indexes to add, remove, or change.
Read all database queries in src/repositories/ and the Eloquent/ORM calls
in src/models/. Suggest indexes based on the WHERE clauses, JOIN conditions,
and ORDER BY columns. Generate the migration to add them.
Claude traces every query path and maps columns to their index needs:
Suggested indexes:
+ orders(customer_id, status) — used in WHERE customer_id = ? AND status = ?
+ products(category_id, created_at) — used in WHERE category_id = ? ORDER BY created_at
+ users(email) UNIQUE — used in WHERE email = ? (login, password reset)
Redundant indexes to remove:
- orders(customer_id) — covered by the composite index above
- products(created_at) — rarely queried alone, covered by composite
Missing from common queries:
⚠ users(last_login_at) — the dashboard sorts all users by last login
but there's no index, causing a full table scan on every page load
Target specific index optimization needs:
# Analyze slow queries
Read the slow query log (or the queries flagged by your monitoring tool)
and suggest indexes that would fix each one.
# Check for over-indexing
List every index on every table. Flag indexes that overlap with other
indexes or that exist on columns that are never used in WHERE or JOIN clauses.
# Composite index ordering
Check if any composite indexes have their columns in the wrong order.
The most selective column should usually come first.
# Partial and conditional indexes
For tables with soft deletes, suggest partial indexes that exclude
deleted rows — smaller indexes that only cover the rows queries actually need.
The right index turns a 5-second query into 5 milliseconds — let Claude read your queries and tell you exactly which columns need indexing.
via Claude Code
Log in to leave a comment.
Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.
Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.
Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.