---
sidebar_position: 1
title: EXPLAIN ANALYZE
description: Execute a query and display performance metrics for each operator.
---
# EXPLAIN ANALYZE

`EXPLAIN ANALYZE` displays and executes the query plan, showing performance metrics and cardinality information for each operator.

:::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 ANALYZE <SQL query>
```

## Example Usage

```sql
EXPLAIN ANALYZE
SELECT 1 AS col
UNION ALL
FROM (SELECT vendorId
FROM sample_data.nyc.taxi LIMIT 1);
```

This will return the analyzed plan, which shows which elements of the query are running locally and some are running remotely on MotherDuck.

```text
┌─────────────────────────────────────┐
│┌───────────────────────────────────┐│
││    Query Profiling Information    ││
│└───────────────────────────────────┘│
└─────────────────────────────────────┘
EXPLAIN ANALYZE SELECT 1 AS col UNION ALL FROM (SELECT vendorId FROM sample_data.nyc.taxi LIMIT 1) 
-- MD_SQL_METADATA: {"source":"hatchling","purpose":"runCellStatement","containsUserSQL":true}
┌────────────────────────────────────────────────┐
│┌──────────────────────────────────────────────┐│
││              Total Time: 0.0955s             ││
│└──────────────────────────────────────────────┘│
└────────────────────────────────────────────────┘
┌───────────────────────────┐
│           QUERY           │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│         EXTENSION         │
│    ────────────────────   │
│          md_type:         │
│   HYBRID_STATS_COLLECTOR  │
│                           │
│           0 Rows          │
│          (0.00s)          │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│      EXPLAIN_ANALYZE      │
│    ────────────────────   │
│           0 Rows          │
│          (0.00s)          │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│         EXTENSION         │
│    ────────────────────   │
│          md_type:         │
│       HYBRID_RUNNER       │
│                           │
│           0 Rows          │
│          (0.00s)          │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│         EXTENSION         │
│    ────────────────────   │
│          md_type:         │
│      DOWNLOAD_SOURCE      │
│                           │
│        bridge_id: 1       │
│                           │
│           2 Rows          │
│          (0.00s)          │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│         EXTENSION         │
│    ────────────────────   │
│          md_type:         │
│       DOWNLOAD_SINK       │
│                           │
│        bridge_id: 1       │
│      parallel: false      │
│                           │
│           0 Rows          │
│          (0.00s)          │
└─────────────┬─────────────┘
┌─────────────┴─────────────┐
│           UNION           │
│    ────────────────────   │
│           2 Rows          ├──────────────┐
│          (0.00s)          │              │
└─────────────┬─────────────┘              │
┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│         PROJECTION        ││      STREAMING_LIMIT      │
│    ────────────────────   ││    ────────────────────   │
│            col            ││                           │
│                           ││                           │
│           1 Rows          ││           1 Rows          │
│          (0.00s)          ││          (0.00s)          │
└─────────────┬─────────────┘└─────────────┬─────────────┘
┌─────────────┴─────────────┐┌─────────────┴─────────────┐
│         DUMMY_SCAN        ││         TABLE_SCAN        │
│    ────────────────────   ││    ────────────────────   │
│                           ││        Table: taxi        │
│                           ││   Type: Sequential Scan   │
│                           ││   Projections: VendorID   │
│                           ││                           │
│           1 Rows          ││         4096 Rows         │
│          (0.00s)          ││          (0.00s)          │
└───────────────────────────┘└───────────────────────────┘
```


