为提高效率,请提供以下信息,问题描述清晰能够更快得到解决:
【 TiDB 使用环境】
5.4
【概述】 场景 + 问题概述
【背景】 做过哪些操作
【现象】 业务和数据库现象
查询速度慢 时间不稳定。
【问题】 当前遇到的问题,参考 AskTUG 的 Troubleshooting 读性能慢-慢语句
【统计信息是否最新】
表的健康度查了下是93
【执行计划内容】
Projection_7 1.00 1 root time:3.24s, loops:2, Concurrency:OFF aweme_encryption.device.id, aweme_encryption.device.access, aweme_encryption.device.aid, aweme_encryption.device.apk_first_install_time, aweme_encryption.device.app_name, aweme_encryption.device.app_package, aweme_encryption.device.app_type, aweme_encryption.device.app_version, aweme_encryption.device.appkey, aweme_encryption.device.apptheme, aweme_encryption.device.ban_at, aweme_encryption.device.ban_count, aweme_encryption.device.ban_type, aweme_encryption.device.bind_phone, aweme_encryption.device.cdid, aweme_encryption.device.channel, aweme_encryption.device.channel_id, aweme_encryption.device.city, aweme_encryption.device.clientudid, aweme_encryption.device.cookie, aweme_encryption.device.cpu_abi, aweme_encryption.device.cpu_support64, aweme_encryption.device.create_at, aweme_encryption.device.device_brand, aweme_encryption.device.device_id, aweme_encryption.device.device_manufacturer, aweme_encryption.device.device_model, aweme_encryption.device.device_platform, aweme_encryption.device.device_token, aweme_encryption.device.display_density, aweme_encryption.device.display_name, aweme_encryption.device.dpi, aweme_encryption.device.git_hash, aweme_encryption.device.install_id, aweme_encryption.device.is_ban, aweme_encryption.device.is_reject, aweme_encryption.device.is_simulate, aweme_encryption.device.is_system_app, aweme_encryption.device.language, aweme_encryption.device.mac, aweme_encryption.device.magic_tag, aweme_encryption.device.manifest_version_code, aweme_encryption.device.minor_status, aweme_encryption.device.not_request_sender, aweme_encryption.device.oaid, aweme_encryption.device.oaid_may_support, aweme_encryption.device.openudid, aweme_encryption.device.os, aweme_encryption.device.os_api, aweme_encryption.device.os_version, aweme_encryption.device.pick_count, aweme_encryption.device.pre_installed_channel, aweme_encryption.device.region, aweme_encryption.device.rejected_at, aweme_encryption.device.release_build, aweme_encryption.device.resolution, aweme_encryption.device.rom, aweme_encryption.device.rom_version, aweme_encryption.device.sdk_flavor, aweme_encryption.device.sdk_target_version, aweme_encryption.device.sdk_version, aweme_encryption.device.sig_hash, aweme_encryption.device.sn, aweme_encryption.device.ssmix, aweme_encryption.device.timezone, aweme_encryption.device.tz_name, aweme_encryption.device.tz_offset, aweme_encryption.device.udid, aweme_encryption.device.update_version_code, aweme_encryption.device.updated_at, aweme_encryption.device.user_agent, aweme_encryption.device.version_code, aweme_encryption.device.version_name 39.0 KB N/A
└─Limit_12 1.00 1 root time:3.24s, loops:2 offset:0, count:1 N/A N/A
└─IndexLookUp_31 1.00 1 root time:3.24s, loops:1, index_task: {total_time: 3.24s, fetch_handle: 157.9ms, build: 62.1ms, wait: 3.02s}, table_task: {total_time: 15.7s, num: 28, concurrency: 5} 75.2 MB N/A
├─IndexRangeScan_28(Build) 20.19 290619 cop[tikv] table:device0_, index:idx_is_ban_pick_count(is_ban, pick_count) time:136.9ms, loops:292, cop_task: {num: 6, max: 191.6ms, min: 465µs, avg: 33.8ms, p95: 191.6ms, max_proc_keys: 170371, p95_proc_keys: 170371, tot_proc: 175ms, tot_wait: 8ms, rpc_num: 6, rpc_time: 202.8ms, copr_cache_hit_ratio: 0.67}, tikv_task:{proc max:557ms, min:0s, p80:525ms, p95:557ms, iters:301, tasks:6}, scan_detail: {total_process_keys: 170371, total_process_keys_size: 9370405, total_keys: 481193, rocksdb: {delete_skipped_count: 35, key_skipped_count: 481226, block: {cache_hit_count: 292, read_count: 0, read_byte: 0 Bytes}}} range:[0,0], keep order:true N/A N/A
└─Selection_30(Probe) 1.00 50019 cop[tikv] time:15.5s, loops:81, cop_task: {num: 156, max: 3.03s, min: 442.1µs, avg: 131.3ms, p95: 761.3ms, max_proc_keys: 18671, p95_proc_keys: 2344, tot_proc: 18.2s, tot_wait: 890ms, rpc_num: 156, rpc_time: 20.5s, copr_cache_hit_ratio: 0.90}, tikv_task:{proc max:371ms, min:0s, p80:38ms, p95:134ms, iters:492, tasks:156}, scan_detail: {total_process_keys: 66635, total_process_keys_size: 76915888, total_keys: 86393, rocksdb: {delete_skipped_count: 26706, key_skipped_count: 96794, block: {cache_hit_count: 428526, read_count: 0, read_byte: 0 Bytes}}} eq(aweme_encryption.device.app_version, "16.8.0") N/A N/A
└─TableRowIDScan_29 20.19 188384 cop[tikv] table:device0_ tikv_task:{proc max:369ms, min:0s, p80:38ms, p95:134ms, iters:492, tasks:156} keep order:false N/A N/A
【 SQL 文本、schema 以及 数据分布】
# Time: 2022-03-10T15:22:02.621267251+08:00
# Txn_start_ts: 431724146042077210
# User@Host: aweme_encryption_user[aweme_encryption_user] @ 10.165.0.207 [10.165.0.207]
# Conn_ID: 255617
# Query_time: 3.183456646
# Parse_time: 0.00029965
# Compile_time: 0.002087851
# Rewrite_time: 0.000321452
# Optimize_time: 0.001108982
# Wait_TS: 0.000018281
# Cop_time: 5.714274076 Process_time: 6.078 Wait_time: 4.621 Request_count: 159 Process_keys: 193278 Total_keys: 379990 Rocksdb_delete_skipped_count: 184690 Rocksdb_key_skipped_count: 608805 Rocksdb_block_cache_hit_count: 216587
# DB: aweme_encryption
# Index_names: [device:idx_is_ban_pick_count]
# Is_internal: false
# Digest: c9882ea23e1bdf464454c70ce463b162a8e6d8442f4b8e29f5aab5db9cf99a1e
# Stats: device:431724024840060951
# Num_cop_tasks: 159
# Cop_proc_avg: 0.038226415 Cop_proc_p90: 0.001 Cop_proc_max: 1.418 Cop_proc_addr: 172.18.150.41:20160
# Cop_wait_avg: 0.029062893 Cop_wait_p90: 0.064 Cop_wait_max: 0.097 Cop_wait_addr: 172.18.150.41:20160
# Mem_max: 19015169
# Prepared: false
# Plan_from_cache: false
# Plan_from_binding: false
# Has_more_results: false
# KV_total: 18.355833734
# PD_total: 0.000014164
# Backoff_total: 0
# Write_sql_response_total: 0.00003083
# Result_rows: 1
# Succ: true
# IsExplicitTxn: false
# Plan: tidb_decode_plan('7CGYMAkzXzcJMAkxCWF3ZW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ODMwOIpoAgQzMwE5AGtGZgIUMTMwNTYxamYCFDIxNjIyMU1aTXqCaQIYNAk0NV8yOUVqVgMFncUoZmFsc2UJMTQ1NzCBxkbgAwQyOGXMQUNOdwFFNlJ3ASAJTi9BCU4vQQo=')
# Plan_digest: f59a68551d20799ffad8f265dee8c1cbf58a76aa1261edb5c116a7fba0a77ba1
select device0_.id as id1_0_, device0_.access as access2_0_, device0_.aid as aid3_0_, device0_.apk_first_install_time as apk_firs4_0_, device0_.app_name as app_name5_0_, device0_.app_package as app_pack6_0_, device0_.app_type as app_type7_0_, device0_.app_version as app_vers8_0_, device0_.appkey as appkey9_0_, device0_.apptheme as appthem10_0_, device0_.ban_at as ban_at11_0_, device0_.ban_count as ban_cou12_0_, device0_.ban_type as ban_typ13_0_, device0_.bind_phone as bind_ph14_0_, device0_.cdid as cdid15_0_, device0_.channel as channel16_0_, device0_.channel_id as channel17_0_, device0_.city as city18_0_, device0_.clientudid as clientu19_0_, device0_.cookie as cookie20_0_, device0_.cpu_abi as cpu_abi21_0_, device0_.cpu_support64 as cpu_sup22_0_, device0_.create_at as create_23_0_, device0_.device_brand as device_24_0_, device0_.device_id as device_25_0_, device0_.device_manufacturer as device_26_0_, device0_.device_model as device_27_0_, device0_.device_platform as device_28_0_, device0_.device_token as device_29_0_, device0_.display_density as display30_0_, device0_.display_name as display31_0_, device0_.dpi as dpi32_0_, device0_.git_hash as git_has33_0_, device0_.install_id as install34_0_, device0_.is_ban as is_ban35_0_, device0_.is_reject as is_reje36_0_, device0_.is_simulate as is_simu37_0_, device0_.is_system_app as is_syst38_0_, device0_.language as languag39_0_, device0_.mac as mac40_0_, device0_.magic_tag as magic_t41_0_, device0_.manifest_version_code as manifes42_0_, device0_.minor_status as minor_s43_0_, device0_.not_request_sender as not_req44_0_, device0_.oaid as oaid45_0_, device0_.oaid_may_support as oaid_ma46_0_, device0_.openudid as openudi47_0_, device0_.os as os48_0_, device0_.os_api as os_api49_0_, device0_.os_version as os_vers50_0_, device0_.pick_count as pick_co51_0_, device0_.pre_installed_channel as pre_ins52_0_, device0_.region as region53_0_, device0_.rejected_at as rejecte54_0_, device0_.release_build as release55_0_, device0_.resolution as resolut56_0_, device0_.rom as rom57_0_, device0_.rom_version as rom_ver58_0_, device0_.sdk_flavor as sdk_fla59_0_, device0_.sdk_target_version as sdk_tar60_0_, device0_.sdk_version as sdk_ver61_0_, device0_.sig_hash as sig_has62_0_, device0_.sn as sn63_0_, device0_.ssmix as ssmix64_0_, device0_.timezone as timezon65_0_, device0_.tz_name as tz_name66_0_, device0_.tz_offset as tz_offs67_0_, device0_.udid as udid68_0_, device0_.update_version_code as update_69_0_, device0_.updated_at as updated70_0_, device0_.user_agent as user_ag71_0_, device0_.version_code as version72_0_, device0_.version_name as version73_0_ from device device0_ where device0_.app_version='16.8.0' and device0_.is_ban=0 order by device0_.pick_count asc limit 1;
【业务影响】
【TiDB 版本】
【附件】 相关日志及监控(https://metricstool.pingcap.com/)
- TiUP Cluster Display 信息
- TiUP CLuster Edit config 信息
- TiDB-Overview Grafana监控
- TiDB Grafana 监控
- TiKV Grafana 监控
- PD Grafana 监控
- 对应模块日志(包含问题前后 1 小时日志)