【 TiDB 使用环境】测试环境
【 TiDB 版本】v5.4.0
【遇到的问题】
执行delete操作后,查询很慢,花费2分钟,执行delete后tiflash如何删除数据?
【复现路径】做过哪些操作出现的问题
1、一张表:query_slow_test,200w条数据,启用表同步到tiflash存储
2、同步完成,查询很快,SELECT ds from query_slow_test group by ds ;
3、执行delete数据操作,DELETE FROM query_slow_test where ds <= ‘2022-05-30’
4、delete执行快1分钟完成后,执行同样查询,花费2分钟。SELECT ds from query_slow_test group by ds ;
【问题现象及影响】
1、删除计划
id task estRows operator info actRows execution info memory disk
Delete_4 root 0 N/A 0 time:13.2s, loops:1, commit_txn: {prewrite:18.9s, get_commit_ts:219.4µs, commit:284.2ms, region_num:3, write_keys:2691534, write_byte:51139146} 48.9 MB N/A
└─TableReader_8 root 930116.25 data:Selection_7 2691534 time:1.45s, loops:2634, cop_task: {num: 3, max: 1.75s, min: 1.42s, avg: 1.58s, p95: 1.75s, max_proc_keys: 1102421, p95_proc_keys: 1102421, tot_proc: 4.12s, rpc_num: 3, rpc_time: 4.74s, copr_cache_hit_ratio: 0.00} 296.1 MB N/A
└─Selection_7 cop[tikv] 930116.25 le(test.query_slow_test.ds, 2022-05-30 00:00:00.000000) 2691534 tikv_task:{proc max:1.18s, min:976ms, p80:1.18s, p95:1.18s, iters:2688, tasks:3}, scan_detail: {total_process_keys: 2738745, total_process_keys_size: 279492445, total_keys: 2738748, rocksdb: {delete_skipped_count: 0, key_skipped_count: 2738745, block: {cache_hit_count: 1935, read_count: 2867, read_byte: 20.3 MB}}} N/A N/A
└─TableFullScan_6 cop[tikv] 2798745 table:query_slow_test, keep order:false 2738745 tikv_task:{proc max:1.14s, min:952ms, p80:1.14s, p95:1.14s, iters:2688, tasks:3} N/A N/A
2、查询计划
id task estRows operator info actRows execution info memory disk
TableReader_31 root 48 data:ExchangeSender_30 1 time:1m58.4s, loops:2, cop_task: {num: 1, max: 0s, proc_keys: 0, copr_cache_hit_ratio: 0.00} N/A N/A
└─ExchangeSender_30 cop[tiflash] 48 ExchangeType: PassThrough 1 tiflash_task:{time:1m58.4s, loops:1, threads:20} N/A N/A
└─Projection_26 cop[tiflash] 48 test.query_slow_test.ds 1 tiflash_task:{time:1m58.4s, loops:1, threads:20} N/A N/A
└─HashAgg_27 cop[tiflash] 48 group by:test.query_slow_test.ds, funcs:firstrow(test.query_slow_test.ds)->test.query_slow_test.ds 1 tiflash_task:{time:1m58.4s, loops:1, threads:1} N/A N/A
└─ExchangeReceiver_29 cop[tiflash] 48 1 tiflash_task:{time:1m58.4s, loops:1, threads:20} N/A N/A
└─ExchangeSender_28 cop[tiflash] 48 ExchangeType: HashPartition, Hash Cols: [name: test.query_slow_test.ds, collate: N/A] 1 tiflash_task:{time:1m58.4s, loops:1, threads:6} N/A N/A
└─HashAgg_9 cop[tiflash] 48 group by:test.query_slow_test.ds, 1 tiflash_task:{time:1m58.4s, loops:1, threads:1} N/A N/A
└─TableFullScan_25 cop[tiflash] 2738745 table:query_slow_test, keep order:false 47211 tiflash_task:{time:1m58.4s, loops:4, threads:6} N/A N/A
3、慢查询时间
【附件】 相关日志及监控(https://metricstool.pingcap.com/)
若提问为性能优化、故障排查类问题,请下载脚本运行。终端输出的打印结果,请务必全选并复制粘贴上传。