A plausible answer can be the wrong production change
Paste a slow EXPLAIN plan into an assistant and it may suggest a missing index or a query rewrite. That can be useful as a hypothesis. It does not establish that this statement dominates the workload, that the plan caused the user's wait, or that the proposed index improves the system after its write and storage costs are included.
For example, a query with a good plan can still be slow because it is blocked behind a transaction. The first useful evidence is then the blocker and wait timeline, not another index. Conversely, a fast individual query executed thousands of times per request can dominate total database time. Single-plan analysis misses both patterns.
Put the artifact back into its workload
- Frequency and total cost: compare calls, mean and tail latency, and total execution time for important statements. A rare outlier and a frequent moderate query need different priorities.
- Waits and concurrency: check whether the session was using CPU, reading I/O, waiting on a lock or sitting behind a saturated pool. See the lock contention guide.
- Data distribution: compare representative parameter values, actual versus estimated rows and plan shapes. A prepared statement may behave differently for large and small tenants.
- Change history: relate the symptom to releases, data growth, statistics, configuration, version changes or a new workload.
- Side effects: estimate how a new index affects writes, memory, disk and maintenance, or how a setting affects other statements.
Use AI where it helps
AI can explain plan nodes, propose diagnostic queries and help compare candidate changes. It can also miss a relevant constraint or assume the supplied sample represents production. Treat its answer as an analysis aid. Confirm each important assertion against the source plan, PostgreSQL documentation and workload evidence before acting.
A useful output states: the observation, the evidence reference, the hypothesis, competing explanations, confidence, change risk and a before-and-after test. The sample investigation report shows that structure using a measured synthetic lab. PostgreSQL's EXPLAIN guide explains why row estimates, loops and actual measurements matter when reading plans.
When to ask for a deeper investigation
If the same symptom has several plausible causes, a change could harm another workload, or the team cannot name a validation metric, the decision needs more than a query suggestion. A bounded PostgreSQL performance investigation ranks the evidence and defines a safe test order.