Documentation

EXPLAIN command

The EXPLAIN command returns the logical plan and the physical execution plan for the specified SQL statement.

EXPLAIN [ANALYZE] [VERBOSE] statement

EXPLAIN

Returns the execution plan of a statement. To output more details, use EXPLAIN VERBOSE.

EXPLAIN doesn’t execute the statement. To execute the statement and view runtime metrics, use EXPLAIN ANALYZE.

Example EXPLAIN

EXPLAIN
SELECT
  room,
  avg(temp) AS temp
FROM home
GROUP BY room

View EXPLAIN example output

EXPLAIN ANALYZE

Executes a statement and returns the execution plan and runtime metrics of the statement. The report includes the logical plan and the physical plan annotated with execution counters, number of rows produced, and runtime metrics sampled during the query execution.

EXPLAIN and EXPLAIN ANALYZE may show a truncated list of the files scanned for a query if the plan requires reading lots of data files, To output more information, including intermediate plans and paths for all scanned parquet files, use EXPLAIN ANALYZE VERBOSE.

Example EXPLAIN ANALYZE
EXPLAIN ANALYZE
SELECT
  room,
  avg(temp) AS temp
FROM home
GROUP BY room

View EXPLAIN ANALYZE example output

EXPLAIN ANALYZE VERBOSE

Executes a statement and returns the execution plan, runtime metrics, and additional details helpful for debugging the statement.

The report includes the following:

  • the logical plan
  • the physical plan annotated with execution counters, number of rows produced, and runtime metrics sampled during the query execution
  • Information truncated in the EXPLAIN report–for example, the paths for all files retrieved for the query.
  • All intermediate physical plans that the IOx querier and DataFusion generate before the query engine generates the final physical plan–helpful in debugging to see when an operator is added or removed in a plan, and how InfluxDB and DataFusion optimize the query. The report includes:

Example EXPLAIN ANALYZE VERBOSE

EXPLAIN VERBOSE SELECT temp FROM home
WHERE time >= now() - INTERVAL '90 days' AND room = 'Kitchen'
ORDER BY time

Was this page helpful?

Thank you for your feedback!


Introducing InfluxDB Clustered

A highly available InfluxDB 3.0 cluster on your own infrastructure.

InfluxDB Clustered is a highly available InfluxDB 3.0 cluster built for high write and query workloads on your own infrastructure.

InfluxDB Clustered is currently in limited availability and is only available to a limited group of InfluxData customers. If interested in being part of the limited access group, please contact the InfluxData Sales team.

Learn more
Contact InfluxData Sales

The future of Flux

Flux is going into maintenance mode. You can continue using it as you currently are without any changes to your code.

Flux is going into maintenance mode and will not be supported in InfluxDB 3.0. This was a decision based on the broad demand for SQL and the continued growth and adoption of InfluxQL. We are continuing to support Flux for users in 1.x and 2.x so you can continue using it with no changes to your code. If you are interested in transitioning to InfluxDB 3.0 and want to future-proof your code, we suggest using InfluxQL.

For information about the future of Flux, see the following: