Unable to pushdown projection to tikv/tiflash when using limit option
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### 1. Minimal reproduce step (Required)
```sql
CREATE TABLE `json_t` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`json_c` json DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `json_t`(`json_c`)
VALUES
('{"name": "tanaka", "gender": 1, "options": {"x": 100, "y": 200}}'),
('{"name": "yamada", "gender": 2, "options": {"x": 300}}'),
('{"name": "suzuki", "gender": 1, "options": {"x": 100, "y": 200, "z": [1, 3, 4]}}');
set session tidb_opt_projection_push_down='ON';
explain analyze SELECT `json_c`->"$.name" FROM `json_t`;
explain analyze SELECT `json_c`->"$.name" FROM `json_t` limit 3;
alter table json_t set tiflash replica 1;
explain analyze SELECT `json_c`->"$.name" FROM `json_t`;
explain analyze SELECT `json_c`->"$.name" FROM `json_t` limit 3;
```
### 2. What did you expect to see? (Required)
Do projection on tikv or tiflash even there is a limit option as well.
### 3. What did you see instead (Required)
```
+--------------------------------+---------+---------+--------------+---------------+---------------------------------------------------------------------------------------+-----------------------------------------------------+-----------+------+
| id | estRows | actRows | task | access object | execution info | operator info | memory | disk |
+--------------------------------+---------+---------+--------------+---------------+---------------------------------------------------------------------------------------+-----------------------------------------------------+-----------+------+
| Projection_6 | 3.00 | 3 | root | | time:13.8ms, loops:2, Concurrency:OFF | json_extract(plaid.json_t.json_c, $.name)->Column#3 | 636 Bytes | N/A |
| └─Limit_9 | 3.00 | 3 | root | | time:13.8ms, loops:2 | offset:0, count:3 | N/A | N/A |
| └─TableReader_17 | 3.00 | 3 | root | | time:13.8ms, loops:1, cop_task: {num: 1, max: 0s, proc_keys: 0, copr_cache: disabled} | data:ExchangeSender_16 | N/A | N/A |
| └─ExchangeSender_16 | 3.00 | 0 | mpp[tiflash] | | | ExchangeType: PassThrough | N/A | N/A |
| └─Limit_15 | 3.00 | 0 | mpp[tiflash] | | | offset:0, count:3 | N/A | N/A |
| └─TableFullScan_14 | 3.00 | 0 | mpp[tiflash] | table:json_t | | keep order:false, stats:pseudo | N/A | N/A |
+--------------------------------+---------+---------+--------------+---------------+---------------------------------------------------------------------------------------+-----------------------------------------------------+-----------+------+
```
### 4. What is your TiDB version? (Required)
```
mysql> SELECT tidb_version();
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v6.5.0
Edition: Enterprise
Git Commit Hash: 706c3fa3c526cdba5b3e9f066b1a568fb96c56e3
Git Branch: heads/refs/tags/v6.5.0
UTC Build Time: 2022-12-27 03:51:11
GoVersion: go1.19.3
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: tikv |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
```
Contributor guide
Assessment
This issue has not been assessed yet.