Reading EXPLAIN ANALYZE
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
read a plan tree and spot the problem node.
Planned topics
EXPLAINshows the estimated plan;EXPLAIN (ANALYZE, BUFFERS)runs the query and adds actual rows, time, and page reads.- Read inner-most, most-indented nodes first; time is per loop, multiply by
loops. - Compare
rows=(estimate) withactual rows=; big gaps point to bad statistics. - Scan types:
Seq Scan,Index Scan,Index Only Scan,Bitmap Heap Scan. ANALYZEreally executes the statement; wrapINSERT/UPDATE/DELETEin a transaction and roll back.
Draft outline details
Demonstration
EXPLAIN (ANALYZE, BUFFERS)
SELECT * FROM orders WHERE customer_id = 4711 ORDER BY created_at DESC LIMIT 20;Annotate node type, estimated vs actual rows, Buffers: shared hit/read, and execution time.
Check your understanding
Why is plain EXPLAIN not enough to find a slow node?
Show answer
It shows only estimates, not actual rows or time.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.