---
sidebar_position: 1
title: EXPLAIN
description: Display the physical query plan without executing the query.
---
# EXPLAIN

The `EXPLAIN` statement shows the physical query plan that will be executed. It displays a tree of operators that will run in sequence to produce the query results. The query optimizer transforms this plan to improve performance.

On MotherDuck queries, `(L)` indicates queries that are executed **locally** and `(R)` indicates the queries are executed **remotely**.

For more detailed query analysis, review the documentation on [`EXPLAIN ANALYZE`](/sql-reference/motherduck-sql-reference/explain-analyze/).

:::note
The [query profiling guide on DuckDB](https://duckdb.org/docs/stable/dev/profiling.html) is a great place to start with this topic.
:::

## Syntax

This SQL query shows the physical query plan for an example query.

```sql
EXPLAIN <SQL query>
```

## Example Usage

```sql
EXPLAIN
SELECT 1 AS col
UNION ALL
SELECT 2
```

This will return the physical plan, which executes entirely locally.

```text
Physical Plan
┌───────────────────────────┐
│         UNION (L)         ├──────────────┐
└─────────────┬─────────────┘              │
┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│       PROJECTION (L)      ││       PROJECTION (L)      │
│    ────────────────────   ││    ────────────────────   │
│            col            ││             2             │
│                           ││                           │
│          ~1 Rows          ││          ~1 Rows          │
└─────────────┬─────────────┘└─────────────┬─────────────┘
┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│       DUMMY_SCAN (L)      ││       DUMMY_SCAN (L)      │
└───────────────────────────┘└───────────────────────────┘
```

### `EXPLAIN` in MotherDuck compared to DuckDB
The MotherDuck `EXPLAIN` plan is similar to the DuckDB `EXPLAIN` plan, with two main differences:

* Operations that run locally are marked as (L), and operations running remotely on the MotherDuck service are marked as (R).
* The MotherDuck DuckDB extension adds four new type of custom operators, to exchange data between your local DuckDB and the MotherDuck service:
  * The **`UploadSink`** operator runs locally and sends data from your local DuckDB to the remote MotherDuck service.
  * The **`UploadSource`** operator runs remotely in the DuckDB on the MotherDuck side and consumes the uploaded data.
  * The **`DownloadSink`** operator runs remotely on the MotherDuck side and prepares the data to be downloaded by the local DuckDB.
  * The **`DownloadSource`** operator runs in your local DuckDB, fetching the data from the MotherDuck service made available via the remote DownloadSink.





---

## Docs feedback

MotherDuck accepts optional user-submitted feedback about this page at `POST https://motherduck.com/docs/api/feedback/agent`.
For agents and automated tools, feedback submission should be user-confirmed before sending.

Payload:

```json
{
  "page_path": "/sql-reference/motherduck-sql-reference/explain/",
  "page_title": "EXPLAIN",
  "text": "<the user's feedback, max 2000 characters>",
  "source": "<optional identifier for your interface, for example 'claude.ai' or 'chatgpt'>"
}
```

`page_path` and `text` are required; `page_title` and `source` are optional. Responses: `200 {"feedback_id": "<uuid>"}`, `400` for malformed payloads, and `429` when rate-limited.
