pingcap / pingcap/tidb

planner: Plan Cache is not compatible with CTE

Open
#54,130 2 comments 0 reactions 0 assignees View on GitHub
sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement
If a query has any CTE tables, the optimizer will skip Plan Cache for this table, see the case below:
```
mysql> create table tt (a int);
Query OK, 0 rows affected (0.02 sec)

mysql> prepare st from "with tx as (select a from t) select * from tx;";
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> execute st;
Empty set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+-------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------------------------------+
| Warning | 1105 | skip prepared plan-cache: find table test.tx failed: [schema:1146]Table 'test.tx' doesn't exist |
+---------+------+-------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.