# Execution Plan Cache
+ Enabled by default since `v6.1.0`
+ Prepare: Query is parsed into an Abstract Syntax Tree `(AST)` and cached
+ Execute `(1st)`:
  + Execution plan is generated based on the `AST` and parameters values if any
  + Put the plan into plan cache implemented by `LRU` linked list
+ Execute `(2nd+)`: Obtain the execution plan from the plan cache
```
tidb> SELECT @@~!@tidb_enable_prepared_plan_cache@!~;
+-----------------------------------+
| @@tidb_enable_prepared_plan_cache |
+-----------------------------------+
|                                 ~!@1@!~ |
+-----------------------------------+
```
![`smart`](./student-guide/diagram/ExecutionPlanCache_en_001_20220810.png)
-----------------------------
When preparing, the parameterized query is parsed into an Abstract Syntax Tree `(AST)` and cached; in later execution, the execution plan is generated based on the stored `AST` and specific parameter values.

When the execution plan cache is enabled, in the first execution every Prepare statement checks whether the current query can use the execution plan cache, and if the query can use it, then put the generated execution plan into a cache implemented by Least Recently Used `(LRU)` linked list. In the subsequent Execute queries, the execution plan is obtained from the cache and checked for availability. If the check succeeds, the step of generating an execution plan is skipped. Otherwise, the execution plan is regenerated and saved in the cache. 