Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.Original topic: tidb limit执行计划疑惑
[TiDB Usage Environment] Production Environment / Test / Poc
Poc
[TiDB Version]
5.1.4
[Encountered Problem]
Why is the actRows in the execution plan at the TiKV layer 7 for the following SQL with limit 1 (Limit_28(Build))? Shouldn’t it be 1? Please help take a look, thank you.
desc analyze SELECT status
, expiry_time
FROM modell_var_tab force index (idx_tag_entity) WHERE tag_id = 8884146564707019816 AND (entity_id >= 470781680 AND entity_type >= ‘user’) ORDER BY entity_id, entity_type LIMIT 1;
±-------------------------------------±--------±--------±----------±---------------------------------------------------------------------------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------±--------±-----+
| id | estRows | actRows | task | access object | execution info | operator info | memory | disk |
±-------------------------------------±--------±--------±----------±---------------------------------------------------------------------------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------±--------±-----+
| Projection_8 | 0.84 | 1 | root | | time:3.27ms, loops:2, Concurrency:OFF | userdb_tes_mode_aa_db.modell_var_tab.status, userdb_tes_mode_aa_db.modell_var_tab.expiry_time | 2.07 KB | N/A |
| └─Limit_14 | 0.84 | 1 | root | | time:3.26ms, loops:2 | offset:0, count:1 | N/A | N/A |
| └─Projection_30 | 0.84 | 1 | root | | time:3.26ms, loops:1, Concurrency:OFF | userdb_tes_mode_aa_db.modell_var_tab.entity_id, userdb_tes_mode_aa_db.modell_var_tab.entity_type, userdb_tes_mode_aa_db.modell_var_tab.tag_id, userdb_tes_mode_aa_db.modell_var_tab.status, userdb_tes_mode_aa_db.modell_var_tab.expiry_time | 2.43 KB | N/A |
| └─IndexLookUp_29 | 0.84 | 1 | root | | time:3.26ms, loops:1, index_task: {total_time: 1.11ms, fetch_handle: 1.1ms, build: 3.82µs, wait: 3.14µs}, table_task: {total_time: 15.4ms, num: 3, concurrency: 5} | | 7.48 KB | N/A |
| ├─Limit_28(Build) | 0.84 | 7 | cop[tikv] | | time:1.1ms, loops:4, cop_task: {num: 7, max: 1.07ms, min: 854µs, avg: 953.3µs, p95: 1.07ms, max_proc_keys: 32, p95_proc_keys: 32, tot_proc: 2ms, tot_wait: 1ms, rpc_num: 7, rpc_time: 6.6ms, copr_cache_hit_ratio: 0.00}, tikv_task:{proc max:1ms, min:0s, p80:1ms, p95:1ms, iters:7, tasks:7}, scan_detail: {total_process_keys: 224, total_keys: 231, rocksdb: {delete_skipped_count: 0, key_skipped_count: 224, block: {cache_hit_count: 91, read_count: 1, read_byte: 31.2 KB}}} | offset:0, count:1 | N/A | N/A |
| │ └─Selection_27 | 0.84 | 224 | cop[tikv] | | tikv_task:{proc max:1ms, min:0s, p80:1ms, p95:1ms, iters:7, tasks:7} | ge(userdb_tes_mode_aa_db.modell_var_tab.entity_type, “user”) | N/A | N/A |
| │ └─IndexRangeScan_25 | 0.84 | 224 | cop[tikv] | table:modell_var_tab, index:idx_tag_entity(tag_id, entity_id, entity_type) | tikv_task:{proc max:1ms, min:0s, p80:1ms, p95:1ms, iters:7, tasks:7} | range:[8884146564707019816 470781680,8884146564707019816 +inf], keep order:true | N/A | N/A |
| └─TableRowIDScan_26(Probe) | 0.84 | 7 | cop[tikv] | table:modell_var_tab | time:1.82ms, loops:6, cop_task: {num: 7, max: 601.6µs, min: 518.9µs, avg: 564.6µs, p95: 601.6µs, max_proc_keys: 1, p95_proc_keys: 1, rpc_num: 7, rpc_time: 3.89ms, copr_cache_hit_ratio: 0.00}, tikv_task:{proc max:0s, min:0s, p80:0s, p95:0s, iters:7, tasks:7}, scan_detail: {total_process_keys: 7, total_keys: 7, rocksdb: {delete_skipped_count: 0, key_skipped_count: 0, block: {cache_hit_count: 84, read_count: 0, read_byte: 0 Bytes}}} | keep order:false, stats:pseudo | N/A | N/A |
±-------------------------------------±--------±--------±----------±---------------------------------------------------------------------------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------±---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------±--------±-----+
[Reproduction Path] What operations were performed to encounter the problem
[Problem Phenomenon and Impact]
[Attachments]
Please provide the version information of each component, such as cdc/tikv, which can be obtained by executing cdc version/tikv-server --version.