pingcap/tidb
在 GitHub 查看planner: Limit cannot be pushed down through IndexLookUp when the keep-order is true and it has a table-side Selection
Open
#21,250 创建于 2020年11月24日
help wantedreport/customersig/plannertype/enhancement
仓库指标
- Star
- (40,090 star)
- PR 合并指标
- (平均合并 14天 4小时) (30 天内合并 346 个 PR)
描述
Development Task
mysql> create table t (a int, b int, key(a));
mysql> explain select * from t where b>10 order by a limit 1;
+-----------------------------------+---------+-----------+---------------------+--------------------------------+
| id | estRows | task | access object | operator info |
+-----------------------------------+---------+-----------+---------------------+--------------------------------+
| Limit_12 | 1.00 | root | | offset:0, count:1 |
| └─Projection_25 | 1.00 | root | | test.t.a, test.t.b |
| └─IndexLookUp_24 | 1.00 | root | | |
| ├─IndexFullScan_21(Build) | 3.00 | cop[tikv] | table:t, index:a(a) | keep order:true, stats:pseudo |
| └─Selection_23(Probe) | 1.00 | cop[tikv] | | gt(test.t.b, 10) |
| └─TableRowIDScan_22 | 3.00 | cop[tikv] | table:t | keep order:false, stats:pseudo |
+-----------------------------------+---------+-----------+---------------------+--------------------------------+
In the case above, we can push Limit down to the probe side to get a better plan:
Limit root
Projection root
IndexLookUp root
IndexFullScan cop
Limit cop
Selection cop
TableRowIDScan cop