MySQL 慢查询日报(线上 prod8891)2026-11-03
统计概览
| 项目 | 值 |
|---|
| 统计范围 | 2026-11-03 00:00:00 ~ 23:59:59(Asia/Shanghai) |
| 环境 | prod-8891 |
| 慢日志条数(ES mysql-slow_*) | 20,197 条(指纹聚合取样 20,197 条) |
| Top10 单条最慢 | 297.25 s(user=t8891,YCJF_t8891_26) |
| 非备份模式最大累计 | 5.77h(3748 次 × 5.55 s) |
| 备份模式(user 含 backup/databasus_backup) | 0 条、累计 0.0s(单独标注,不触发深析) |
| 深析模式 explain 成功率 | 7/8(88%) |
| 数据来源 | ES mysql-slow_*(@timestamp)+ MCP 只读 MySQL(describe_schema/explain) |
| 生成时间 | 2026-11-04 09:31(Asia/Shanghai) |
Top10 明细(按单条耗时)
| # | 耗时(s) | 库.表 | 行数 sent/examined | user / server | 慢因分类 |
|---|
| 1 | 297.25 | t8891.t_carinfo_coupon_activity | 2,094 / 657,646 | t8891 / YCJF_t8891_26 | 扫描行数远大于返回行数(657,646/2,094) |
| 2 | 291.18 | t8891.t_carinfo_coupon_activity | 2,094 / 657,646 | t8891 / YCJF_t8891_26 | 扫描行数远大于返回行数(657,646/2,094) |
| 3 | 287.94 | t8891.t_carinfo_coupon_activity | 2,094 / 657,646 | t8891 / YCJF_t8891_25_3307 | 扫描行数远大于返回行数(657,646/2,094) |
| 4 | 287.63 | t8891.t_carinfo_coupon_activity | 2,094 / 657,655 | t8891 / YCJF_t8891_26 | 扫描行数远大于返回行数(657,655/2,094) |
| 5 | 286.71 | t8891.t_carinfo_coupon_activity | 2,094 / 657,646 | t8891 / YCJF_t8891_25 | 扫描行数远大于返回行数(657,646/2,094) |
| 6 | 286.27 | t8891.t_carinfo_coupon_activity | 2,091 / 657,640 | t8891 / YCJF_t8891_25 | 扫描行数远大于返回行数(657,640/2,091) |
| 7 | 284.73 | t8891.t_carinfo_coupon_activity | 2,094 / 657,664 | t8891 / YCJF_t8891_25 | 扫描行数远大于返回行数(657,664/2,094) |
| 8 | 283.82 | t8891.t_carinfo_coupon_activity | 2,094 / 658,042 | t8891 / YCJF_t8891_25_3307 | 扫描行数远大于返回行数(658,042/2,094) |
| 9 | 283.40 | t8891.t_carinfo_coupon_activity | 2,094 / 657,646 | t8891 / YCJF_t8891_25_3307 | 扫描行数远大于返回行数(657,646/2,094) |
| 10 | 283.19 | t8891.t_carinfo_coupon_activity | 2,091 / 657,640 | t8891 / YCJF_t8891_25_3307 | 扫描行数远大于返回行数(657,640/2,091) |
高频慢查询模式(指纹聚合,取样 20,197 条)
按条数 Top5
| # | 模式(指纹摘要) | 条数 | 平均(s) | 累计 | server | user |
|---|
| 1 | select * from t_member_devices where (m_id = ? and hash = ?) limit ?; | 3,748 | 5.55 | 5.77h | YCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2 | t8891 |
| 2 | select * from t_carinfo_inquiry_agent where expire_status = ? and expire_time <= ?; | 1,440 | 1.92 | 46.1min | YCJF_t8891_24 | t8891 |
| 3 | select max(record_time) as aggregate from t_carinfo_inquiry_call_log; | 1,432 | 1.19 | 28.5min | YCJF_t8891_24 | t8891 |
| 4 | select f_id, COUNT(*) count from t_carinfo_favorite where m_id IN (?...) and type = ? and exists (select * from t_carinfo_search_base_kind where t_carinfo_favorite.f_id = t_carinfo_search_base_kind.kind_id and sale_stop = ?) group by f_id order by count desc limit ?; | 1,360 | 5.05 | 1.91h | YCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2 | t8891 |
| 5 | select * from t_carinfo_inquiry_agent where contact_status = ? and expire_status = ?; | 1,317 | 1.94 | 42.6min | YCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2 | t8891 |
按累计耗时 Top5
| # | 模式 | 条数 | 平均(s) | 累计 | server | user |
|---|
| 1 | select * from t_member_devices where (m_id = ? and hash = ?) limit ?; | 3,748 | 5.55 | 5.77h | YCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2 | t8891 |
| 2 | select f_id, COUNT(*) count from t_carinfo_favorite where m_id IN (?...) and type = ? and exists (select * from t_carinfo_search_base_kind where t_carinfo_favorite.f_id = t_carinfo_search_base_kind.kind_id and sale_stop = ?) group by f_id order by count desc limit ?; | 1,360 | 5.05 | 1.91h | YCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2 | t8891 |
| 3 | select t_carinfo_coupon_activity.* from t_carinfo_coupon_activity left join t_carinfo_coupon_activity_callback as b on t_carinfo_coupon_activity.id = b.activity …(点击展开完整 SQL)select t_carinfo_coupon_activity.* from t_carinfo_coupon_activity left join t_carinfo_coupon_activity_callback as b on t_carinfo_coupon_activity.id = b.activity_item_id left join t_carinfo_agent_call_to_bidding as c on t_carinfo_coupon_activity.m_id = c.m_id and c.type = ? and phase = ? and c.created_at > ? where (t_carinfo_coupon_activity.type = ?) and b.payment_time is null and t_carinfo_coupon_activity.m_id > ? and c.id is null; | 20 | 281.98 | 1.57h | YCJF_t8891_25,YCJF_t8891_25_3307,YCJF_t8 | t8891 |
| 4 | select * from t_carinfo_inquiry_agent where expire_status = ? and expire_time <= ?; | 1,440 | 1.92 | 46.1min | YCJF_t8891_24 | t8891 |
| 5 | select * from t_carinfo_inquiry_agent where contact_status = ? and expire_status = ?; | 1,317 | 1.94 | 42.6min | YCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2 | t8891 |
备份模式全天 0 条 / 0.0s,未触发深度分析(如条数环比异常翻倍再人工介入)。
触发深度分析的模式(条数>100 或 累计>30min,非备份,最多 8 个)
1. select * from t_member_devices where (m_id = ? and hash = ?) limit ?; —— 3,748 次 × 5.55s = 5.77h
select * from `t_member_devices` where (`m_id` = 342660 and `hash` = '9cd5cfca5f484f5c9867ceb31aa450fd') limit 1;
- 库表:t8891.t_member_devices;实例 alias:
prod-8891/master
- explain SQL:
select * from `t8891`.`t_member_devices` where (`m_id` = 342660 and `hash` = '9cd5cfca5f484f5c9867ceb31aa450fd') limit 1;
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | t_member_devices | ref | t_member_devices_m_id_index | t_member_devices_m_id_index | 800,297 | 10.0% |
- 慢因:扫描行数远大于返回行数(3,826,519/0)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
- 可执行 DDL(建议先在低峰期 EXPLAIN 验证再执行):
ALTER TABLE `t8891`.`t_member_devices` ADD INDEX `idx_m_id_hash` (`m_id`, `hash`);
- DDL 注:
t_member_devices 与现有索引 t_member_devices_m_id_index(m_id) 前缀重复(m_id), 新索引生效后可评估删除旧索引
2. select f_id, COUNT(*) count from t_carinfo_favorite where m_id IN (?...) and type = ? and exists (select * from t_carinfo_search_base_kind where t_carinfo_favor —— 1,360 次 × 5.05s = 1.91h
select f_id, COUNT(*) count from `t_carinfo_favorite` where `m_id` in (0, 28471, 87996, 146404, 165146, 176738, 222791, 230291, 232584, 247415, 248889, 248942, 249085, 250052, 255277, 262791, 264730, 273812, 281804, 281876, 284518, 293200, 298373, 298887, 301023, 303646, 305130, 305994, 306212, 306939, 308503, 309346, 316711, 322903, 325763, 325970, 326202, 327960, 329301, 329408, 330018, 330885, 334298, 336316, 339260, 339857, 343073, 343669, 344475, 347718, 347780, 348020, 350882, 351334, 351431, 351761, 351979, 352624, 352700, 354592, 355425, 356385, 358218, 358838, 361064, 362250, 362808, 363508, 363627, 364057, 368099, 369164, 372146, 374583, 376347, 380628, 383545, 387635, 389116, 392556, 395410, 395754, 396452, 397688, 400030, 401099, 401769, 403847, 404705, 405925, 408589, 409995, 411059, 411881, 412183, 413313, 414218, 414917, 414969, 416063, 416204, 416717, 416760, 417835, 418271, 419873, 420258, 421618, 421763, 426030, 428234, 431794, 432261, 432518, 432568, 432916, 435466, 437197, 437328, 438373, 439017, 442150, 442248, 443535, 443867, 445661, 445705, 446409, 446557, 446909, 446910, 446999, 447608, 447616, 447877, 448140, 448659, 450341, 451969, 452106, 453270, 455876, 456043, 456586, 456678, 456753, 457896, 458485, 459738, 460540, 460710, 461408, 461522, 461751, 464331, 465434, 466145, 466844, 466865, 467391, 467799, 468763, 471069, 471610, 473645, 473782, 474639, 474861, 475788, 475929, 476105, 477935, 478064, 478129, 481141, 487935, 495900, 496122, 496621, 498706, 501726, 506682, 506878, 507411, 517077, 520836, 526408, 526456, 527254, 532716, 533026, 534461, 535072, 535524, 535855, 536751, 538506, 539389, 540285, 540569, 541434, 542074, 542628, 543269, 544862, 545349, 546408, 547700, 547935, 548699, 548896, 549040, 552311, 553243, 553510, 559273, 563528, 563764, 564030, 564438, 564644, 565483, 566049, 566122, 566703, 567390, 568060, 568661, 569784, 574333, 574520, 575634, 575674, 576905, 577515, 577797, 579347, 580187, 581390, 581417, 583004, 583130, 584163, 584293, 584860, 585415, 586083, 586107, 590523, 594515, 596544, 597123, 597214, 597506, 600603, 605128, 607267, 607271, 607441, 608192, 609515, 611760, 615644, 616146, 616176, 616467, 616734, 618243, 624418, 625752, 626689, 627045, 628476, 628841, 628872, 632783, 634162, 635077, 635198, 635769, 636173, 637533, 637632, 637674, 639297, 640236, 640428, 640852, 641881, 642641, 643344, 644580, 645600, 649735, 650655, 655543, 655929, 656623, 657563, 658735, 659099, 659334, 661874, 663214, 663830, 664525, 665533, 665752, 666390, 666731, 666839, 671212, 671605, 675107, 676843, 677667, 678512, 680781, 680979, 684476, 686049, 686884, 693146, 693226, 694495, 698910, 700497, 702941, 703704, 704049, 704853, 705557, 706379, 707036, 709159, 710245, 710667, 711445, 712214, 712659, 718965, 722901, 724112, 724366, 725338, 727833, 727848, 728276, 729810, 731715, 732037, 733122, 734096, 734185, 735726, 737163, 747670, 761762, 773824, 777685, 778305, 780397, 781376, 781591, 784699, 790483, 796563, 800754, 804182, 806755, 807769, 808925, 809470, 810905, 811181, 813943, 814136, 816662, 817037, 817325, 817427, 818918, 819779, 820260, 822571, 824571, 830079, 830753, 832339, 832588, 835263, 835400, 836341, 838477, 838554, 839126, 839731, 847715, 850894, 852344, 856002, 860621, 861268, 863674, 867155, 868281, 869208, 870148, 870241, 870642, 870982, 874179, 877445, 887823, 891648, 899872, 903296, 903416, 905741, 914697, 914978, 915577, 916125, 918618, 919884, 923305, 923774, 927130, 930934, 932603, 933510, 933557, 935146, 940908, 952987, 958538, 960956, 967470, 970065, 971168, 971239, 972482, 975203, 977616, 980141, 980493, 981053, 982437, 988561, 989623, 989821, 991324, 991835, 996323, 1003861, 1004619, 1009407, 1011193, 1013564, 1014654, 1019857, 1024677, 1025187, 1027241, 1030886, 1036515, 1042955, 1044827, 1047054, 1052508, 1054762, 1055278, 1059049, 1061858, 1062483, 1062867, 1068889, 1070350, 1071154, 1073167, 1085016, 1085085, 1088712, 1089221, 1089443, 1091674, 1092208, 1097647
- 库表:t8891.t_carinfo_favorite;实例 alias:
prod-8891/master
- explain:未执行(Error calling tool 'explain': (1054, "Unknown column 'sale_stop' in 'where clause'"))
- 慢因:扫描行数远大于返回行数(1,834,592/6)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
- 可执行 DDL(建议先在低峰期 EXPLAIN 验证再执行):
ALTER TABLE `t8891`.`t_carinfo_favorite` ADD INDEX `idx_sale_stop` (`sale_stop`);
3. select t_carinfo_coupon_activity.* from t_carinfo_coupon_activity left join t_carinfo_coupon_activity_callback as b on t_carinfo_coupon_activity.id = b.activity —— 20 次 × 281.98s = 1.57h
select t_carinfo_coupon_activity.* from `t_carinfo_coupon_activity` left join `t_carinfo_coupon_activity_callback` as `b` on `t_carinfo_coupon_activity`.`id` = `b`.`activity_item_id` left join `t_carinfo_agent_call_to_bidding` as `c` on `t_carinfo_coupon_activity`.`m_id` = `c`.`m_id` and `c`.`type` = 'callback' and `phase` = 4 and `c`.`created_at` > 't_carinfo_coupon_activity.created_at' where (`t_carinfo_coupon_activity`.`type` = 4) and `b`.`payment_time` is null and `t_carinfo_coupon_activity`.`m_id` > 0 and `c`.`id` is null;
- 库表:t8891.t_carinfo_coupon_activity;实例 alias:
prod-8891/master
- explain SQL:
select t_carinfo_coupon_activity.* from `t8891`.`t_carinfo_coupon_activity` left join `t8891`.`t_carinfo_coupon_activity_callback` as `b` on `t_carinfo_coupon_activity`.`id` = `b`.`activity_item_id` left join `t8891`.`t_carinfo_agent_call_to_bidding` as `c` on `t_carinfo_coupon_activity`.`m_id` = `c`.`m_id` and `c`.`type` = 'callback' and `phase` = 4 and `c`.`created_at` > 't_carinfo_coupon_activity.created_at' where (`t_carinfo_coupon_activity`.`type` = 4) and `b`.`payment_time` is null and `t_carinfo_coupon_activity`.`m_id` > 0 and `c`.`id` is null;
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | t_carinfo_coupon_activity | ref | idx_type | idx_m_id,idx_type | 3,720 | 50.0% |
| 2 | b | ❌ 全表扫描 | — | — | 1,217 | 10.0% |
| 3 | c | ❌ 全表扫描 | — | — | 474,233 | 10.0% |
- 慢因:扫描行数远大于返回行数(658,042/2,094)、EXPLAIN 全表扫描/未用索引
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
- 可执行 DDL(建议先在低峰期 EXPLAIN 验证再执行):
ALTER TABLE `t8891`.`t_carinfo_coupon_activity` ADD INDEX `idx_type_m_id` (`type`, `m_id`);
ALTER TABLE `t8891`.`t_carinfo_coupon_activity_callback` ADD INDEX `idx_activity_i_payment_ti` (`activity_item_id`, `payment_time`);
ALTER TABLE `t8891`.`t_carinfo_agent_call_to_bidding` ADD INDEX `idx_m_id_phase_type_created_at` (`m_id`, `phase`, `type`, `created_at`);
- DDL 注:
t_carinfo_coupon_activity 与现有索引 idx_type(type) 前缀重复(type), 新索引生效后可评估删除旧索引
4. select * from t_carinfo_inquiry_agent where expire_status = ? and expire_time <= ?; —— 1,440 次 × 1.92s = 46.1min
select * from `t_carinfo_inquiry_agent` where `expire_status` = 0 and `expire_time` <= '2026-11-03 16:21:11';
- 库表:t8891.t_carinfo_inquiry_agent;实例 alias:
prod-8891/master
- explain SQL:
select * from `t8891`.`t_carinfo_inquiry_agent` where `expire_status` = 0 and `expire_time` <= '2026-11-03 16:21:11';
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | t_carinfo_inquiry_agent | ❌ 全表扫描 | — | — | 1,898,612 | 3.33% |
- 慢因:扫描行数远大于返回行数(2,415,481/76)、EXPLAIN 全表扫描/未用索引
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
- 可执行 DDL(建议先在低峰期 EXPLAIN 验证再执行):
ALTER TABLE `t8891`.`t_carinfo_inquiry_agent` ADD INDEX `idx_expire_sta_expire_tim` (`expire_status`, `expire_time`);
5. select * from t_carinfo_inquiry_agent where contact_status = ? and expire_status = ?; —— 1,317 次 × 1.94s = 42.6min
select * from `t_carinfo_inquiry_agent` where `contact_status` = 0 and `expire_status` = 0;
- 库表:t8891.t_carinfo_inquiry_agent;实例 alias:
prod-8891/master
- explain SQL:
select * from `t8891`.`t_carinfo_inquiry_agent` where `contact_status` = 0 and `expire_status` = 0;
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | t_carinfo_inquiry_agent | ❌ 全表扫描 | — | — | 1,898,612 | 1.0% |
- 慢因:扫描行数远大于返回行数(2,415,481/952)、EXPLAIN 全表扫描/未用索引
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
- 可执行 DDL(建议先在低峰期 EXPLAIN 验证再执行):
ALTER TABLE `t8891`.`t_carinfo_inquiry_agent` ADD INDEX `idx_contact_st_expire_sta` (`contact_status`, `expire_status`);
6. select max(record_time) as aggregate from t_carinfo_inquiry_call_log; —— 1,432 次 × 1.19s = 28.5min
select max(`record_time`) as aggregate from `t_carinfo_inquiry_call_log`;
- 库表:t8891.t_carinfo_inquiry_call_log;实例 alias:
prod-8891/master
- explain SQL:
select max(`record_time`) as aggregate from `t8891`.`t_carinfo_inquiry_call_log`;
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | t_carinfo_inquiry_call_log | ❌ 全表扫描 | — | — | 1,658,596 | 100.0% |
- 慢因:扫描行数远大于返回行数(2,240,428/1)、EXPLAIN 全表扫描/未用索引
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
- 可执行 DDL(建议先在低峰期 EXPLAIN 验证再执行):
ALTER TABLE `t8891`.`t_carinfo_inquiry_call_log` ADD INDEX `idx_record_tim` (`record_time`);
- DDL 注:MAX/MIN 聚合:
record_time 单列索引可让优化器走索引取极值, 亦可改写为 ORDER BY record_time DESC/ASC LIMIT 1
7. select t_vincheck_supervision.* from t_vincheck_supervision left join t_vincheck_supervision_info on t_vincheck_supervision_info.vincheck_supervision_id = t_vin —— 288 次 × 4.06s = 19.5min
select `t_vincheck_supervision`.* from `t_vincheck_supervision` left join `t_vincheck_supervision_info` on `t_vincheck_supervision_info`.`vincheck_supervision_id` = `t_vincheck_supervision`.`id` where `t_vincheck_supervision`.`is_exist` = 1 and `t_vincheck_supervision`.`type` = 1 and `t_vincheck_supervision_info`.`id` is null order by `t_vincheck_supervision`.`id` asc limit 500;
- 库表:t8891.t_vincheck_supervision;实例 alias:
prod-8891/master
- explain SQL:
select `t_vincheck_supervision`.* from `t8891`.`t_vincheck_supervision` left join `t8891`.`t_vincheck_supervision_info` on `t_vincheck_supervision_info`.`vincheck_supervision_id` = `t_vincheck_supervision`.`id` where `t_vincheck_supervision`.`is_exist` = 1 and `t_vincheck_supervision`.`type` = 1 and `t_vincheck_supervision_info`.`id` is null order by `t_vincheck_supervision`.`id` asc limit 500;
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | t_vincheck_supervision | ref | is_exist | is_exist,idx_type | 495,157 | 50.0% |
| 2 | t_vincheck_supervision_info | eq_ref | idx_vincheck_supervision_id | idx_vincheck_supervision_id | 1 | 10.0% |
- 慢因:扫描行数远大于返回行数(1,045,238/62)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
- 可执行 DDL(建议先在低峰期 EXPLAIN 验证再执行):
ALTER TABLE `t8891`.`t_vincheck_supervision` ADD INDEX `idx_is_exist_type` (`is_exist`, `type`);
- DDL 注:
t_vincheck_supervision 与现有索引 is_exist(is_exist) 前缀重复(is_exist), 新索引生效后可评估删除旧索引
8. select count(*) as aggregate from v_items where item_class = ? and item_display_status = ? and new_kind_id = ?; —— 674 次 × 1.60s = 17.9min
select count(*) as aggregate from `v_items` where `item_class` = 1 and `item_display_status` = 1 and `new_kind_id` = 10844;
- 库表:t8891.v_items;实例 alias:
prod-8891/master
- explain SQL:
select count(*) as aggregate from `t8891`.`v_items` where `item_class` = 1 and `item_display_status` = 1 and `new_kind_id` = 10844;
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | t_sele_item_data | ref | idx_display_status_n_item_id | item_id,item_class,idx_display_status_n_item_id | 71,874 | 50.0% |
| 2 | t_sele_item_infos | ref | item_id | new_kind_id,item_id | 1 | 5.0% |
| 3 | t_sele_items | eq_ref | PRIMARY | PRIMARY | 1 | 100.0% |
- 慢因:扫描行数远大于返回行数(124,050/1)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
- 可执行 DDL(建议先在低峰期 EXPLAIN 验证再执行):
ALTER TABLE `t8891`.`v_items` ADD INDEX `idx_item_class_item_displ_new_kind_i` (`item_class`, `item_display_status`, `new_kind_id`);
逐条优化建议汇总
P 行 = 深析模式(指纹聚合,按全天累计耗时降序 P1 最大,是优化主战场);T 行 = 单条耗时 Top3 的一次性慢 SQL(多为 bi/导出查询,治理手段通常是限流/降频/移到从库,而非建索引)。
| 编号 | 对象 | 建议 |
|---|
| P1 | t8891.t_member_devices(3,748×5.5s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_member_devices ADD INDEX idx_m_id_hash (m_id, hash); |
| P2 | t8891.t_carinfo_favorite(1,360×5.1s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_favorite ADD INDEX idx_sale_stop (sale_stop); |
| P3 | t8891.t_carinfo_coupon_activity(20×282.0s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_coupon_activity ADD INDEX idx_type_m_id (type, m_id); ALTER TABLE t8891.t_carinfo_coupon_activity_callback ADD INDEX idx_activity_i_payment_ti (activity_item_id, payment_time); ALTER TABLE t8891.t_carinfo_agent_call_to_bidding ADD INDEX idx_m_id_phase_type_created_at (m_id, phase, type, created_at); |
| P4 | t8891.t_carinfo_inquiry_agent(1,440×1.9s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_inquiry_agent ADD INDEX idx_expire_sta_expire_tim (expire_status, expire_time); |
| P5 | t8891.t_carinfo_inquiry_agent(1,317×1.9s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_inquiry_agent ADD INDEX idx_contact_st_expire_sta (contact_status, expire_status); |
| P6 | t8891.t_carinfo_inquiry_call_log(1,432×1.2s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_inquiry_call_log ADD INDEX idx_record_tim (record_time); |
| P7 | t8891.t_vincheck_supervision(288×4.1s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_vincheck_supervision ADD INDEX idx_is_exist_type (is_exist, type); |
| P8 | t8891.v_items(674×1.6s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.v_items ADD INDEX idx_item_class_item_displ_new_kind_i (item_class, item_display_status, new_kind_id); |
| T1 | Top1(同 P3 对象) 单条最慢 5.0min,user=t8891 t8891.t_carinfo_coupon_activity | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库 |
| T2 | Top2(同 P3 对象) 单条最慢 4.9min,user=t8891 t8891.t_carinfo_coupon_activity | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库 |
| T3 | Top3(同 P3 对象) 单条最慢 4.8min,user=t8891 t8891.t_carinfo_coupon_activity | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库 |
*采集脚本 .agents/scripts/mysql_slow_prod_report.py,中间数据 outputs/slow_report_prod8891_20261103.json;全程只读。*