Documentation

EXPLAIN command

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

EXPLAIN [ANALYZE] [VERBOSE] statement
  • Copy
  • Fill window

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
  • Copy
  • Fill window

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
  • Copy
  • Fill window

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
  • Copy
  • Fill window

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

New in InfluxDB 3.2

Key enhancements in InfluxDB 3.2 and the InfluxDB 3 Explorer UI is now generally available.

See the Blog Post

InfluxDB 3.2 is now available for both Core and Enterprise, bringing the general availability of InfluxDB 3 Explorer, a new UI that simplifies how you query, explore, and visualize data. On top of that, InfluxDB 3.2 includes a wide range of performance improvements, feature updates, and bug fixes including automated data retention and more.

For more information, check out: