</>CodexBash
All articles
Databases

Reading a query plan

How to read EXPLAIN and EXPLAIN ANALYZE output to find out why a query is slow: plan trees, sequential and index scans, index-only and bitmap scans, nested loop, hash and merge joins, estimated versus actual rows, buffers, sorting and memory, and a step-by-step method for fixing slow queries in PostgreSQL and MySQL.

CodexBash, , 7 min read

When a query is slow, guessing is a waste of time. The database will tell you exactly what it is doing if you ask: EXPLAIN shows the query plan, the step-by-step strategy the optimiser chose, and EXPLAIN ANALYZE runs the query and reports what actually happened at each step, with timings and row counts. Reading plans is the single most useful database performance skill. This article teaches it using PostgreSQL, with notes for MySQL.

Sign in to read the rest

The whole 7 minute article is free with an account, along with every problem, lesson and tutorial. No card.