Your API is slow. You profile it, and the bottleneck is database queries.
But which queries? How many round trips are really happening? Is it a missing index, an N+1 loop, or a join that should be an eager load?
Claude Code reads your entire codebase at once and traces the data flow. It spots patterns humans miss: fetching a list of users, then querying their posts inside a loop. Missing composite indexes on the exact column combinations your WHERE clauses filter. Subqueries that could be joins. Selects pulling back fields you never use.
Here is the workflow:
- Point Claude Code at your app folder and ask it to analyze database queries for performance issues.
- Claude reads your ORM calls (Prisma, SQLAlchemy, whatever), raw SQL, and controller logic together.
- It flags N+1 patterns: looping over results and querying related data item-by-item instead of batching or eager loading.
- It spots missing indexes by reading your queries and schema, finding column combinations that appear in every WHERE clause but lack an index.
- It suggests concrete rewrites: replace that loop with a DataLoader batch, use Prisma include instead of separate queries, add an index on userId and status.
- You measure before and after with profiling. Often you see 10-100x improvements: dashboards dropping from 2.8 seconds to 450ms just by fixing N+1s.
The trick is being systematic: profile first to find the true bottleneck, then let Claude trace exactly why it is happening. Don’t guess. Let the data tell you where the problem is, and let Claude read the code and tell you how to fix it.
Your database is not slow. Your queries are.
——
Book your free AI clarity call, NOW!
https://buff.ly/TpWy277
——
Repost this. Thanks.

Leave a Reply