Database performance problems are not always caused by slow queries. Sometimes the bigger problem is how the application uses the database.
An application might repeatedly fetch data that rarely changes, execute many small queries that could be batched, or hit the database for data that could be cached.
These problems can be difficult to spot when reviewing individual queries because each query may look reasonable on its own.
I use the following prompt to get an AI coding agent to audit the codebase from an architectural perspective.
The Prompt
DB Performance Audit 5: Caching, Batching, and Architectural Improvements — a prompt on Symbol
What This Audit Looks For
The key is that this is not simply an SQL optimization prompt.
It asks the agent to identify unnecessary database access caused by application design. This can reveal repeated reads, missing caching, N+1-style patterns, unnecessary repository calls, and opportunities to batch or reuse data.
It also forces the agent to show the relevant code, explain the impact, recommend a concrete fix, and prioritize findings.
That last part matters. Without prioritization, AI code audits can quickly become long lists of technically valid but low-impact suggestions.
The goal is simple: find architectural changes that can meaningfully reduce database pressure.
