EXPLAIN ANALYZE executes a PostgreSQL statement and displays its execution plan together with actual runtime details. Unlike EXPLAIN alone, it reports Planning Time, Execution Time, actual rows, and loop counts. section 4.4
Inspect an indexed lookup
Run EXPLAIN ANALYZE SELECT username, level, score FROM game.player_stats WHERE player_id = 250;. The plan uses the player_stats_pkey Index Scan, reports actual timing and rows, then shows Planning Time and Execution Time. Repeat the query until timing values become consistent. Because ANALYZE executes the statement, use caution with INSERT, UPDATE, and DELETE. section 4.4
EXPLAIN ANALYZE SELECT username, level, score FROM game.player_stats WHERE player_id = 250;
Runnable SQL for the indexed lookup, paired with its execution plan and timing output. section 4.4
QUERY PLAN ----------------------------------------------------------------- Index Scan using player_stats_pkey on player_stats ➥ (cost=0.29..8.30 rows=1 width=18) ➥ (actual time=0.042..0.044 rows=1 loops=1) Index Cond: (player_id = 250) Buffers: shared hit=3 Planning Time: 0.119 ms Execution Time: 0.076 ms (5 rows)
Extended output shows buffer usage alongside the plan and runtime measurements. section 4.4


