Documentation

EXPLAIN command

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

EXPLAIN [ANALYZE] [VERBOSE] statement

EXPLAIN

Returns the logical plan and physical (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.

If the plan requires reading lots of data files, EXPLAIN and EXPLAIN ANALYZE may truncate the list of files in the report. 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
WHERE time >= '2023-01-01' AND time <= '2023-12-31'
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 Parquet files retrieved for the query.
  • All intermediate physical plans that DataFusion and the Querier generate before generating the final physical plan–helpful in debugging to see when an ExecutionPlan node is added or removed, and how InfluxDB optimizes the query.

Example EXPLAIN ANALYZE VERBOSE

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

Was this page helpful?

Thank you for your feedback!


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.

Read more

InfluxDB v3 enhancements and InfluxDB Clustered is now generally available

New capabilities, including faster query performance and management tooling advance the InfluxDB v3 product line. InfluxDB Clustered is now generally available.

InfluxDB v3 performance and features

The InfluxDB v3 product line has seen significant enhancements in query performance and has made new management tooling available. These enhancements include an operational dashboard to monitor the health of your InfluxDB cluster, single sign-on (SSO) support in InfluxDB Cloud Dedicated, and new management APIs for tokens and databases.

Learn about the new v3 enhancements


InfluxDB Clustered general availability

InfluxDB Clustered is now generally available and gives you the power of InfluxDB v3 in your self-managed stack.

Talk to us about InfluxDB Clustered