Reading PostgreSQL EXPLAIN Plans With LLMs in October 2026: Paste the Real Plan, Make the Model Quote Its Evidence, and Prove Every Fix With a Second Run
A slow query is one of the few performance problems that comes with its own explanation. Run EXPLAIN (ANALYZE, BUFFERS) in PostgreSQL and the database tells you exactly what it did: which tables it scanned, which indexes it used or ignored, how many rows it expected, how many it actually found, and where the time went. The trouble is that a real plan can run to dozens of nested lines, and reading one well takes practice. That makes plan reading a good job to share with a large language model. A model is patient with long, indented output, it knows the vocabulary (Seq Scan, Nested Loop, Hash Join, Bitmap Heap Scan), and it can point you at the suspicious line faster than you can scroll. But it is also happy to recommend an index you do not need, or to "fix" a query in a way that quietly changes its results. This guide covers a workflow that keeps the model useful: give it the real plan, make it explain before it prescribes, and prove every change with a second plan. Step ...