# EXPLAIN

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [cloud-data-platform-full.txt](https://docs.redpanda.com/cloud-data-platform-full.txt)

---
title: EXPLAIN
latest-operator-version: v26.2.6
latest-console-tag: v3.14.0
latest-connect-version: 4.117.0
latest-redpanda-tag: v26.2.6
docname: sql/sql-statements/explain
page-component-name: cloud-data-platform
page-version: master
page-component-version: master
page-component-title: Cloud
page-relative-src-path: sql/sql-statements/explain.adoc
page-edit-url: https://github.com/redpanda-data/cloud-docs/edit/main/modules/reference/pages/sql/sql-statements/explain.adoc
description: The EXPLAIN statement shows the Redpanda SQL query planner options and how long each planning stage takes for a query.
page-topic-type: reference
page-git-created-date: "2026-10-23"
page-git-modified-date: "2026-10-23"
page-generated-content: none
---

<!-- Source: https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-statements/explain.md -->

The `EXPLAIN` statement shows diagnostic information about the Redpanda SQL query planner. Use it to see the query planner options for your session. You can also use it to see how long each planning stage takes for a query.

The `EXPLAIN` statement is a diagnostic tool. Use its output to troubleshoot slow queries. The output can change between releases.

Redpanda SQL `EXPLAIN` is different from PostgreSQL `EXPLAIN`. The forms on this page do not show a query plan. They do not support PostgreSQL options such as `ANALYZE`.

## [](#syntax)Syntax

```sql
EXPLAIN;

EXPLAIN CONFIG;

EXPLAIN TIMING select_statement;
```

-   `CONFIG`: Lists the query planner options for the current session, with their values and descriptions.

-   `TIMING`: Plans the query and lists how long each planning stage takes. Redpanda SQL does not run the query.

-   `select_statement`: The `SELECT` query that `TIMING` plans.


With no option, `EXPLAIN` lists its forms and what each form does. The statement also returns this list if it does not recognize the option. It also returns the list if you add a query to `CONFIG`, or leave the query out of `TIMING`. For example, `EXPLAIN SELECT …​` returns the list, not information about the query.

### [](#explain-function)explain() function

You can also run `EXPLAIN TIMING` and `EXPLAIN CONFIG` with the `explain()` table function. The function returns the same table as the statement. Use its output like any other table to filter, sort, or limit the output with SQL.

```sql
SELECT * FROM explain('select_statement', 'timing');

SELECT * FROM explain('config');
```

Write the query as a string literal. If the query contains a single quote, write it twice, such as `'SELECT * FROM orders WHERE customer = ''alice'''`.

## [](#output)Output

Each form of `EXPLAIN` returns a table. The columns differ by form.

### [](#explain)EXPLAIN

| Column | Description |
| --- | --- |
| query | The form of EXPLAIN. |
| description | What the form does, with an example. |

### [](#explain-config)EXPLAIN CONFIG

| Column | Description |
| --- | --- |
| option | The name of the query planner option, such as oxla.query_planner.optimization.constant_folding. |
| value | The value of the option in the current session. |
| description | What the option does. |

### [](#explain-timing)EXPLAIN TIMING

| Column | Description |
| --- | --- |
| measurement | The planning stage. |
| attribution | Where the time goes: work in the query planner, calls to an external service, or waiting. |
| invocations | The number of times the stage ran. |
| elapsed | The time that the stage takes, in seconds. |

## [](#permissions)Permissions

To run `EXPLAIN TIMING` on a query, you need the privileges to run that query.

## [](#examples)Examples

List the forms of `EXPLAIN`:

```sql
EXPLAIN;
```

List the query planner options for the current session:

```sql
EXPLAIN CONFIG;
```

Show how long each planning stage takes for a query on a topic-backed table:

```sql
EXPLAIN TIMING SELECT count(*) FROM default_redpanda_catalog=>orders;
```

Show the three planning stages that take the longest for the same query:

```sql
SELECT measurement, elapsed
FROM explain('SELECT count(*) FROM default_redpanda_catalog=>orders', 'timing')
ORDER BY elapsed DESC
LIMIT 3;
```

## [](#suggested-reading)Suggested reading

-   [SELECT](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-statements/select/)

-   [SHOW QUERIES](https://docs.redpanda.com/cloud-data-platform/reference/sql/sql-statements/show-queries/)