为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:
【 TiDB 使用环境】线上环境
【概述】业务查询SQL在版本升级之后,查询变得非常慢
【背景】从v4.0.5升级到v5.4.0
【现象】数据库查询太慢,单次查询大概30s左右
【业务影响】查询太慢,频繁超时,无法查看数据。
【TiDB 版本】v5.4.0
【附件】
慢查询面板中的内容如下:
可以看到大量时间都消耗在coprocessor上。
慢查询日志内容:
SELECT l_id,l_oper,l_channel,l_newsid,l_mid,l_user,l_ip,l_opertime,l_workflag,l_updatemode,l_oldstatus,l_newstatus,l_updatenum,l_sql,l_info,l_usertype,l_submit_time,l_timedif
f,l_code,l_submit_type,l_import_type,l_thread,l_thread2,l_parent,l_batch_type,l_wb_url,l_status_mid,l_status_origin,l_status_code,l_site_source,l_distribute_range,l_foul_type
,l_report_type FROM log_cmnt_2022_3 WHERE 1=1 AND l_oper
IN (‘47’, ‘48’) AND l_user
= ‘yusen1’ AND l_distribute_range in (301002) AND l_opertime
< ‘2022-03-23 09:12:1
4’ AND l_opertime
>= ‘2022-03-23 00:00:00’ ORDER BY l_opertime
DESC LIMIT 0,20 ;
# Time: 2022-03-23T09:14:34.755067426+08:00
# Txn_start_ts: 432012803775660102
# User@Host: comment[comment] @ 10.41.23.153 [10.41.23.153]
# Conn_ID: 1484865
# Query_time: 13.439830971
# Parse_time: 0.000101054
# Compile_time: 0.001380275
# Rewrite_time: 0.000345311
# Optimize_time: 0.00090053
# Wait_TS: 0.000016022
# Cop_time: 62.854412561 Process_time: 77.857 Wait_time: 2.342 Request_count: 285 Process_keys: 5600496 Total_keys: 6043251 Rocksdb_delete_skipped_count: 11 Rocksdb_key_skipp
ed_count: 6474692 Rocksdb_block_cache_hit_count: 26316468 Rocksdb_block_read_count: 51 Rocksdb_block_read_byte: 4810077
# DB: comment5_log
# Index_names: [log_cmnt_2022_3:l_channel]
# Is_internal: false
# Digest: 45f3ca3a32e1b721add74bfbaeccc2aac8dcb9094fc7d2397ef0c2d7c1014455
# Stats: log_cmnt_2022_3:pseudo
# Num_cop_tasks: 285
# Cop_proc_avg: 0.273182456 Cop_proc_p90: 0.531 Cop_proc_max: 1.375 Cop_proc_addr: 10.75.18.61:20161
# Cop_wait_avg: 0.008217543 Cop_wait_p90: 0.005 Cop_wait_max: 0.448 Cop_wait_addr: 10.75.18.61:20161
# Mem_max: 26417026
# Prepared: false
# Plan_from_cache: false
# Plan_from_binding: false
# Has_more_results: false
# KV_total: 83.901495422
# PD_total: 0.048708672
# Backoff_total: 0
# Write_sql_response_total: 0.000002302
# Result_rows: 1
# Succ: true
# IsExplicitTxn: false