Skip to content

What is EXPLAIN ANALYZE?

EXPLAIN ANALYZE executes a statement and reports measurements from that execution alongside its plan. Plain EXPLAIN describes the planned work without executing the statement to collect those measurements.

Use an actual plan to compare the database’s estimates with the work a query performs. This can help investigate a slow query after you inspect its estimated plan.

Explain with AI starts with plain EXPLAIN. TableAI asks for confirmation before running EXPLAIN ANALYZE. See explain a query plan with AI for that workflow.

These are the actual-plan forms TableAI uses for PostgreSQL, MySQL, and MariaDB. Each example reads up to ten rows from the Bookstore demo’s books table.

EXPLAIN (ANALYZE, BUFFERS, FORMAT TEXT)
SELECT * FROM books LIMIT 10;

BUFFERS adds buffer access information to the PostgreSQL plan.

For MySQL:

EXPLAIN ANALYZE SELECT * FROM books LIMIT 10;
ANALYZE FORMAT=JSON SELECT * FROM books LIMIT 10;

MariaDB uses ANALYZE FORMAT=JSON for this purpose. Its actual-plan syntax differs from MySQL’s.

An actual execution needs values for parameters such as $1 or ?. For a recorded PostgreSQL, MySQL, or MariaDB query without those values, TableAI asks you to supply them first. Review the completed statement in the SQL editor before execution.

Continue with diagnose database performance to inspect the surrounding workload, or slow query troubleshooting for a timeout.