pingcap / pingcap/tidb

planner: plan cache can't support SQLs like "where pk_col1 = ? and pk_col2 = ? and pk_col3 in (1, 2, 3)"

Open
#53,962 2 comments 0 reactions 1 assignee Claimed by @hawkingrei View on GitHub
epic/plan-cache sig/planner type/enhancement
Dominant language
Go
Stars
40.5k
Forks
6.2k
PR merge metrics
PR metrics pending

Description

## Enhancement
The query below should be able to use Plan Cache:
```
mysql> create table t (a int, b int, c int, d int, primary key (a, b, c));
Query OK, 0 rows affected (0.01 sec)

mysql> prepare st from 'select * from t where a=? and b=? and c in (1,2)';
Query OK, 0 rows affected (0.00 sec)

mysql> set @a=1,@b=2;
Query OK, 0 rows affected (0.00 sec)

mysql> execute st using @a, @b;
Empty set, 1 warning (0.00 sec)

mysql> execute st using @a, @b;
Empty set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+----------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+----------------------------------------------------------------------+
| Warning | 1105 | skip prepared plan-cache: Batch/PointGet plans may be over-optimized |
+---------+------+----------------------------------------------------------------------+
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.