$ recombobulate _
home / tips / ask-claude-to-suggest-database-indexes-based-on-your-query-patterns
141

Ask Claude to Suggest Database Indexes Based on Your Query Patterns

recombobulate @recombobulate · Mar 29, 2026 · Workflows
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

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

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.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

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.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

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.

recombobulate @recombobulate · 1 day ago