【 TiDB 使用环境】生产环境 /测试/ Poc
【 TiDB 版本】7.5.1
【复现路径】
SELECT
*
FROM
xxx
WHERE
next_run_time <= ?
AND id > ?
AND account_monitor_type_id = ?
AND remark = ?
AND state = ?
ORDER BY
id
LIMIT
? [arguments: (1717055486, 0, "11", "3", 1, 1000)];
【遇到的问题:问题现象及影响】
select 语句诱发慢查询导致整体 P99 延迟高
【资源配置】
【附件:截图/日志/监控】
执行计划
| id | estRows | estCost | actRows | task | access object | execution info | operator info | memory | disk |
| Limit_13 | 1000.00 | 393430501.48 | 403 | root | | time:1m33.2s, loops:2 | offset:0, count:1000 | N/A | N/A |
| └─IndexLookUp_47 | 1000.00 | 393430501.48 | 403 | root | | time:1m33.2s, loops:2, index_task: {total_time: 1m32.8s, fetch_handle: 1.74s, build: 3.23s, wait: 1m27.8s}, table_task: {total_time: 7m45.2s, num: 657, concurrency: 5}, next: {wait_index: 8.32ms, wait_table_lookup_build: 402.1µs, wait_table_lookup_resp: 1m33.2s} | | 24.4 MB | N/A |
| ├─IndexRangeScan_44(Build) | 200660.78 | 40834468.62 | 13366428 | cop[tikv] | table:t_rhino_monitor_wemedia_user, index:account_monitor_type_id(account_monitor_type_id) | time:68.9ms, loops:13098, cop_task: {num: 452, max: 153.5ms, min: 1.04ms, avg: 14.9ms, p95: 74.7ms, max_proc_keys: 50144, p95_proc_keys: 50144, tot_proc: 4.76s, tot_wait: 103ms, rpc_num: 452, rpc_time: 6.72s, copr_cache_hit_ratio: 0.67, build_task_duration: 205.6µs, max_distsql_concurrency: 2}, tikv_task:{proc max:134ms, min:0s, avg: 34.2ms, p80:58ms, p95:73ms, iters:14847, tasks:452}, scan_detail: {total_process_keys: 4180992, total_process_keys_size: 192325632, total_keys: 4918093, get_snapshot_time: 32.2ms, rocksdb: {delete_skipped_count: 68, key_skipped_count: 4917946, block: {cache_hit_count: 7466, read_count: 1, read_byte: 16.0 KB, read_time: 56.4µs}}} | range:(11 0,11 +inf], keep order:true | N/A | N/A |
| └─Selection_46(Probe) | 1000.00 | 91856163.66 | 403 | cop[tikv] | | time:7m42.6s, loops:727, cop_task: {num: 689, max: 10s, min: 4.59ms, avg: 675.4ms, p95: 4.89s, max_proc_keys: 20936, p95_proc_keys: 20480, tot_proc: 3m45.3s, tot_wait: 172.9ms, rpc_num: 689, rpc_time: 7m45.3s, copr_cache_hit_ratio: 0.00, build_task_duration: 218.5ms, max_distsql_concurrency: 2}, tikv_task:{proc max:9.95s, min:3ms, avg: 658.5ms, p80:619ms, p95:4.84s, iters:16451, tasks:689}, scan_detail: {total_process_keys: 13366428, total_process_keys_size: 1576436660, total_keys: 17280280, get_snapshot_time: 63.6ms, rocksdb: {delete_skipped_count: 460, key_skipped_count: 14413892, block: {cache_hit_count: 21214777, read_count: 22, read_byte: 574.4 KB, read_time: 4.68ms}}} | eq(dt_datastory_rhino_kol.t_rhino_monitor_wemedia_user.remark, "3"), eq(dt_datastory_rhino_kol.t_rhino_monitor_wemedia_user.state, 1), le(dt_datastory_rhino_kol.t_rhino_monitor_wemedia_user.next_run_time, 1717055486) | N/A | N/A |
| └─TableRowIDScan_45 | 200660.78 | 61817244.69 | 13366428 | cop[tikv] | table:t_rhino_monitor_wemedia_user | tikv_task:{proc max:9.94s, min:3ms, avg: 654.9ms, p80:615ms, p95:4.84s, iters:16451, tasks:689} | keep order:false | N/A | N/A |