NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Senior1 view

What is the difference between EXPLAIN and EXPLAIN ANALYZE?

Practice

Asked at

AI answer

EXPLAIN shows the plan the optimizer intends to use: the estimated access types, indexes, and row counts. It usually does not execute the query itself.

EXPLAIN ANALYZE executes the query and shows actual metrics—for example, the time taken and number of rows processed at each step of the plan. This helps compare the optimizer’s estimates with reality, but the query generates normal database load, so use it cautiously in production. In MySQL, EXPLAIN ANALYZE is available starting with 8.0.18 and uses the TREE format.