Middle
200
What is the difference between EXPLAIN and EXPLAIN ANALYZE?
Answer from AI
sobes.tech AI
EXPLAIN plans the execution of a query, showing the estimated execution plan and approximate cost. It does not execute the query.
EXPLAIN ANALYZE plans and executes the query. It shows the same plan as EXPLAIN, but adds information about actual execution time, the number of rows processed by each plan node, and other statistics obtained during actual execution.
Differences:
| Characteristic | EXPLAIN | EXPLAIN ANALYZE |
|---|---|---|
| Query execution | No | Yes |
| Execution time | Approximate | Actual |
| Number of rows | Estimated | Actual |
| Overhead | Minimal | Higher, as the query is executed |
| Usage | Quick plan retrieval, resource-free analysis | Analysis of real performance, identifying "bottlenecks" |