# SHOW PLAN

Displays the [EXPLAIN](https://docs.singlestore.com/db/v9.1/reference/sql-reference/data-manipulation-language-dml/explain.md) plan of a query as per the plan ID.

## Syntax

```

SHOW PLAN [JSON] plan_id

```

## Remarks

* `SHOW PLAN` displays the same information as `EXPLAIN`. You can use the `SHOW PLAN` command as an alternative to the `EXPLAIN` command, if your database client does not support `EXPLAIN`.
* By default, the `SHOW PLAN` command displays the `EXPLAIN` information of a query in text format. You can optionally choose to display the information in JSON format using the `SHOW PLAN JSON` command.
* You can get the `plan_id` of a query from the `INFORMATION_SCHEMA.PLANCACHE` view. See [Example](https://docs.singlestore.com/#UUID-bc07231c-be4c-726a-e3e1-f2eb91e8e674.md) for details.
* The `SHOW PLAN` command throws the following error if the global variable `enable_disk_plan_explain` is not enabled:
  ```

  ERROR 2394 (HY000): The plan does not have associated explain information. enable_disk_plan_explain must be enabled at the time of plan generation.

  ```
  In this scenario, you need to do the following:

  1. Run the following command to [drop the plan](https://docs.singlestore.com/db/v9.1/reference/sql-reference/data-definition-language-ddl/drop-from-plancache.md) from the plancache:
     ```sql

     DROP 25 FROM PLANCACHE;

     ```

  2. Enable the global variable:
     ```sql

     SET GLOBAL enable_disk_plan_explain=ON;

     ```

  3. Rerun the query to regenerate the plan, and query the plancache again to obtain the new `plan_id`.

  **Note**: Every time a query is run, a new plan is generated along with the `plan_id`.

## Example

The following example displays the plan statistics for the following `SELECT` statement:

```sql

SELECT * FROM Employee;
+------+------+
| ID   | Name |
+------+------+
|   10 | Jack |
|   30 | Ritz |
|   20 | Rob  |
|   40 | Rick |
+------+------+

```

Run the following command to view the plan ID of the `SELECT` query:

```sql

SELECT QUERY_TEXT,PLAN_ID FROM INFORMATION_SCHEMA.PLANCACHE WHERE QUERY_TEXT LIKE 'SELECT * FROM Employee';

```

```output

+---------+------------------------+
| PLAN_ID | QUERY_TEXT             |
+---------+------------------------+
|      25 | SELECT * FROM Employee |
+---------+------------------------+

```

**Note**: In the `SELECT` statement, you can omit the `WHERE` clause to view the plan ID of all the queries executed in the current session.

Now run the following command to view the statistics of the plan ID `25`:

```sql

SHOW PLAN 25;

```

```output

+---------------------------------------------------+
| PLAN                                              |
+---------------------------------------------------+
| Gather partitions:all alias:remote_0              |
| Project [Employee.ID, Employee.Name]              |
| TableScan db.Employee table_type:sharded_rowstore |
+---------------------------------------------------+

```

***

Modified at: October 8, 2021

Source: [/db/v9.1/reference/sql-reference/show-commands/show-plan/](https://docs.singlestore.com/db/v9.1/reference/sql-reference/show-commands/show-plan/)

(An index of the documentation is available at /llms.txt)
