Administration

SQL EXPLAIN ANALYZE

Execute a query and report actual plan statistics on engines that support it.

Availability: Common SQL with references for SQL standard, MySQL/MariaDB, PostgreSQL, SQL Server, SQLite and Oracle Database; syntax and feature support vary by engine and version.中文

Syntax

EXPLAIN ANALYZE query;

Examples

Execute a query and report actual plan statistics on engines that support it.

EXPLAIN ANALYZE SELECT id FROM orders WHERE customer_id = 12;

SQLite-oriented example; consult the relevant dialect manual.

EXPLAIN ANALYZE SELECT id FROM orders WHERE customer_id = 12;

Parameters, options and clauses

Option / clauseDescription
EXPLAINShow the optimizer's planned execution strategy.
ANALYZESome engines execute the statement and report actual statistics; this can run the query.
FORMATChoose plan output format where supported.
Catalog / information schemaInspect objects and definitions through system metadata.
Dialect / versionCheck the linked database manual for vendor-specific behaviour.

Dialect references

Safety note

Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.

Official reference ↗Back to directory