# explain

Source: https://dbmcp.haymon.ai/tools/explain/

Show the execution plan of a SQL query, with optional EXPLAIN ANALYZE on PostgreSQL and MySQL, or ANALYZE on MariaDB

Return the execution plan for a SQL query. Supports an optional `analyze` parameter for actual execution statistics on PostgreSQL and MySQL/MariaDB; MariaDB runs it as `ANALYZE FORMAT=JSON`, its replacement for EXPLAIN ANALYZE. EXPLAIN ANALYZE is only allowed for `SELECT` statements since it actually executes the query, even when read-only mode is disabled. The MySQL or MariaDB form follows [`database.backend`](/features/database), so set it to match the server. Every EXPLAIN runs read-only (see [Read-Only Transactions](/security/read-only#read-only-transactions)), so on MySQL/MariaDB plain EXPLAIN of write statements is rejected; PostgreSQL still plans them. SQLite always uses EXPLAIN QUERY PLAN and does not support ANALYZE. Always available regardless of read-only mode.

On PostgreSQL and MySQL/MariaDB, an optional `timeout` argument (seconds) gives a known-slow `analyze` more time, up to the operator's cap; see [Per-Call Timeout](/features/query-timeouts#per-call-timeout).

Plan row keys follow the column order, as in [`read`](/tools/read).

With [column rules](/privacy/rules#plans-of-ruled-tables), the plan of a statement that touches a ruled table is pruned to value-free keys (plan structure, table and index names, access types, estimates), and `analyze` on such a statement is refused. On MariaDB, `analyze` is refused on every statement while rules exist.