📋 目录统计概览Top10 明细(按单条耗时)高频慢查询模式(指纹聚合,取样 11,477 条触发深度分析的模式(条数>100 或 累计>30逐条优化建议汇总

MySQL 慢查询日报(线上 prod8891)2026-11-01

统计概览

项目值
统计范围2026-11-01 00:00:00 ~ 23:59:59(Asia/Shanghai)
环境prod-8891
慢日志条数(ES mysql-slow_*)11,477 条(指纹聚合取样 11,477 条)
Top10 单条最慢296.51 s(user=t8891,YCJF_t8891_25_3307)
非备份模式最大累计3.88h(2527 次 × 5.52 s)
备份模式(user 含 backup/databasus_backup)0 条、累计 0.0s(单独标注,不触发深析)
深析模式 explain 成功率7/8(88%)
数据来源ES mysql-slow_*(@timestamp)+ MCP 只读 MySQL(describe_schema/explain)
生成时间2026-11-02 09:31(Asia/Shanghai)

Top10 明细(按单条耗时)

#耗时(s)库.表行数 sent/examineduser / server慢因分类
1296.51t8891.t_carinfo_coupon_activity2,092 / 656,970t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(656,970/2,092)
2285.35t8891.t_carinfo_coupon_activity2,092 / 656,970t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(656,970/2,092)
3283.41t8891.t_carinfo_coupon_activity2,091 / 657,321t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(657,321/2,091)
4282.45t8891.t_carinfo_coupon_activity2,091 / 656,976t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(656,976/2,091)
5281.29t8891.t_carinfo_coupon_activity2,091 / 656,982t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(656,982/2,091)
6281.12t8891.t_carinfo_coupon_activity2,092 / 656,970t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(656,970/2,092)
7279.91t8891.t_carinfo_coupon_activity2,092 / 656,970t8891 / YCJF_t8891_25扫描行数远大于返回行数(656,970/2,092)
8279.62t8891.t_carinfo_coupon_activity2,092 / 656,970t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(656,970/2,092)
9276.18t8891.t_carinfo_coupon_activity2,092 / 656,970t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(656,970/2,092)
10275.62t8891.t_carinfo_coupon_activity2,091 / 657,321t8891 / YCJF_t8891_26扫描行数远大于返回行数(657,321/2,091)

高频慢查询模式(指纹聚合,取样 11,477 条)

按条数 Top5

#模式(指纹摘要)条数平均(s)累计serveruser
1select * from t_member_devices where (m_id = ? and hash = ?) limit ?;2,5275.523.88hYCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2t8891
2select 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,1095.001.54hYCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2t8891
3select max(record_time) as aggregate from t_carinfo_inquiry_call_log;9601.1919.1minYCJF_t8891_24t8891
4select * from t_carinfo_inquiry_agent where expire_status = ? and expire_time <= ?;9601.9030.5minYCJF_t8891_24t8891
5select * from t_carinfo_inquiry_agent where contact_status = ? and expire_status = ?;8651.9428.0minYCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2t8891

按累计耗时 Top5

#模式条数平均(s)累计serveruser
1select * from t_member_devices where (m_id = ? and hash = ?) limit ?;2,5275.523.88hYCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2t8891
2select 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,1095.001.54hYCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2t8891
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;
14278.951.08hYCJF_t8891_25,YCJF_t8891_25_3307,YCJF_t8t8891
4select * from t_carinfo_inquiry_agent where expire_status = ? and expire_time <= ?;9601.9030.5minYCJF_t8891_24t8891
5select * from t_carinfo_inquiry_agent where contact_status = ? and expire_status = ?;8651.9428.0minYCJF_t8891_24,YCJF_t8891_25,YCJF_t8891_2t8891
备份模式全天 0 条 / 0.0s,未触发深度分析(如条数环比异常翻倍再人工介入)。

触发深度分析的模式(条数>100 或 累计>30min,非备份,最多 8 个)

1. select * from t_member_devices where (m_id = ? and hash = ?) limit ?; —— 2,527 次 × 5.52s = 3.88h

select * from `t_member_devices` where (`m_id` = 342660 and `hash` = '3e608aa9d993e41c05e0ccc8fb823184') limit 1;
select * from `t8891`.`t_member_devices` where (`m_id` = 342660 and `hash` = '3e608aa9d993e41c05e0ccc8fb823184') limit 1;
#表访问类型使用索引候选索引预扫行数过滤后
1t_member_devicesreft_member_devices_m_id_indext_member_devices_m_id_index800,28610.0%
ALTER TABLE `t8891`.`t_member_devices` ADD INDEX `idx_m_id_hash` (`m_id`, `hash`);

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,109 次 × 5.00s = 1.54h

select f_id, COUNT(*) count from `t_carinfo_favorite` where `m_id` in (0, 61941, 98819, 156565, 159450, 213276, 226594, 237426, 251592, 256314, 256453, 264917, 268565, 281804, 282487, 286454, 289402, 289731, 290335, 291535, 297780, 298526, 303602, 306939, 308748, 309346, 321345, 324115, 334232, 349050, 352246, 354310, 354705, 356307, 365035, 366300, 370356, 370960, 374883, 382677, 383609, 388662, 389189, 392144, 395132, 395644, 399544, 406349, 415525, 417740, 419461, 419574, 424852, 426001, 430336, 432451, 434503, 437878, 438373, 441206, 444599, 446783, 447130, 448436, 452106, 452309, 459255, 462313, 462634, 464736, 466128, 470577, 476868, 478131, 497817, 516231, 517950, 525927, 527090, 535114, 542587, 546939, 549309, 549738, 550817, 561300, 570307, 573918, 576840, 581847, 582688, 584964, 585502, 587410, 588758, 591018, 594733, 595095, 597359, 607905, 609252, 617301, 620100, 633884, 636289, 638698, 640712, 642627, 643344, 647735, 648734, 650975, 652723, 653970, 657993, 659002, 661264, 665266, 666449, 667858, 667996, 672787, 673167, 680506, 689170, 690871, 693632, 693973, 696026, 703225, 704730, 704889, 708055, 708364, 708425, 719986, 724581, 730226, 735035, 737537, 744121, 772800, 775454, 780750, 785119, 793005, 798839, 810597, 821532, 832104, 841833, 850870, 858401, 870258, 894992, 919612, 920732, 931764, 934593, 989779, 992728, 1041058, 1055086, 1061672, 1085463, 1085689, 1098650, 1099555, 1107341, 1118526, 1125334, 1134359, 1136111, 1141274, 1188942, 1191214, 1194193, 1198065, 1279051, 1320154, 1321721, 1353891, 1369857, 1413731, 1436588, 1468356, 1478717, 1499676, 1528942, 1603340) and `type` = 3 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` = 0) group by `f_id` order by `count` desc limit 6;
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 —— 14 次 × 278.95s = 1.08h

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;
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;
#表访问类型使用索引候选索引预扫行数过滤后
1t_carinfo_coupon_activityrefidx_typeidx_m_id,idx_type3,71650.0%
2b❌ 全表扫描——1,21710.0%
3c❌ 全表扫描——474,23310.0%
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`);

4. select * from t_carinfo_inquiry_agent where expire_status = ? and expire_time <= ?; —— 960 次 × 1.90s = 30.5min

select * from `t_carinfo_inquiry_agent` where `expire_status` = 0 and `expire_time` <= '2026-11-01 11:15:09';
select * from `t8891`.`t_carinfo_inquiry_agent` where `expire_status` = 0 and `expire_time` <= '2026-11-01 11:15:09';
#表访问类型使用索引候选索引预扫行数过滤后
1t_carinfo_inquiry_agent❌ 全表扫描——1,898,6713.33%
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 = ?; —— 865 次 × 1.94s = 28.0min

select * from `t_carinfo_inquiry_agent` where `contact_status` = 0 and `expire_status` = 0;
select * from `t8891`.`t_carinfo_inquiry_agent` where `contact_status` = 0 and `expire_status` = 0;
#表访问类型使用索引候选索引预扫行数过滤后
1t_carinfo_inquiry_agent❌ 全表扫描——1,898,6711.0%
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; —— 960 次 × 1.19s = 19.1min

select max(`record_time`) as aggregate from `t_carinfo_inquiry_call_log`;
select max(`record_time`) as aggregate from `t8891`.`t_carinfo_inquiry_call_log`;
#表访问类型使用索引候选索引预扫行数过滤后
1t_carinfo_inquiry_call_log❌ 全表扫描——1,658,596100.0%
ALTER TABLE `t8891`.`t_carinfo_inquiry_call_log` ADD INDEX `idx_record_tim` (`record_time`);

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 —— 192 次 × 4.11s = 13.2min

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;
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;
#表访问类型使用索引候选索引预扫行数过滤后
1t_vincheck_supervisionrefis_existis_exist,idx_type495,15950.0%
2t_vincheck_supervision_infoeq_refidx_vincheck_supervision_ididx_vincheck_supervision_id110.0%
ALTER TABLE `t8891`.`t_vincheck_supervision` ADD INDEX `idx_is_exist_type` (`is_exist`, `type`);

8. select v_items.item_id, v_items.m_id, t_sele_item_update_plan.id as plan_id, t_sele_item_update_plan.type, t_sele_item_update_setting.id, t_sele_item_update_set —— 333 次 × 2.04s = 11.3min

select `v_items`.`item_id`, `v_items`.`m_id`, `t_sele_item_update_plan`.`id` as `plan_id`, `t_sele_item_update_plan`.`type`, `t_sele_item_update_setting`.`id`, `t_sele_item_update_setting`.`time` from `v_items` inner join `t_sele_item_update_plan` on `v_items`.`id` = `t_sele_item_update_plan`.`item_id` inner join `t_sele_item_update_setting` on `t_sele_item_update_plan`.`id` = `t_sele_item_update_setting`.`plan_id` left join `t_sele_item_hidden` on `v_items`.`id` = `t_sele_item_hidden`.`item_id` and `t_sele_item_hidden`.`status` > 0 where `v_items`.`item_display_status` = 1 and `t_sele_item_update_plan`.`status` = 1 and (`t_sele_item_update_setting`.`time` between '17:15:09' and '17:16:08') and `t_sele_item_hidden`.`id` is null;
select `v_items`.`item_id`, `v_items`.`m_id`, `t_sele_item_update_plan`.`id` as `plan_id`, `t_sele_item_update_plan`.`type`, `t_sele_item_update_setting`.`id`, `t_sele_item_update_setting`.`time` from `t8891`.`v_items` inner join `t8891`.`t_sele_item_update_plan` on `v_items`.`id` = `t_sele_item_update_plan`.`item_id` inner join `t8891`.`t_sele_item_update_setting` on `t_sele_item_update_plan`.`id` = `t_sele_item_update_setting`.`plan_id` left join `t8891`.`t_sele_item_hidden` on `v_items`.`id` = `t_sele_item_hidden`.`item_id` and `t_sele_item_hidden`.`status` > 0 where `v_items`.`item_display_status` = 1 and `t_sele_item_update_plan`.`status` = 1 and (`t_sele_item_update_setting`.`time` between '17:15:09' and '17:16:08') and `t_sele_item_hidden`.`id` is null;
#表访问类型使用索引候选索引预扫行数过滤后
1t_sele_item_update_plan❌ 全表扫描—PRIMARY,idx_item_id_status315,86410.0%
2t_sele_item_datarefitem_iditem_id,idx_display_status_n_item_id15.0%
3t_sele_item_infosrefitem_iditem_id1100.0%
4t_sele_itemseq_refPRIMARYPRIMARY1100.0%
5t_sele_item_hiddenrefitem_iditem_id110.0%
6t_sele_item_update_settingrefidx_plan_ididx_plan_id411.11%
ALTER TABLE `t8891`.`v_items` ADD INDEX `idx_id_item_displ` (`id`, `item_display_status`);
ALTER TABLE `t8891`.`t_sele_item_update_plan` ADD INDEX `idx_status` (`status`);
ALTER TABLE `t8891`.`t_sele_item_hidden` ADD INDEX `idx_item_id_status` (`item_id`, `status`);

逐条优化建议汇总

P 行 = 深析模式(指纹聚合,按全天累计耗时降序 P1 最大,是优化主战场);T 行 = 单条耗时 Top3 的一次性慢 SQL(多为 bi/导出查询,治理手段通常是限流/降频/移到从库,而非建索引)。
编号对象建议
P1t8891.t_member_devices(2,527×5.5s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_member_devices ADD INDEX idx_m_id_hash (m_id, hash);
P2t8891.t_carinfo_favorite(1,109×5.0s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_favorite ADD INDEX idx_sale_stop (sale_stop);
P3t8891.t_carinfo_coupon_activity(14×279.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);
P4t8891.t_carinfo_inquiry_agent(960×1.9s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_inquiry_agent ADD INDEX idx_expire_sta_expire_tim (expire_status, expire_time);
P5t8891.t_carinfo_inquiry_agent(865×1.9s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_inquiry_agent ADD INDEX idx_contact_st_expire_sta (contact_status, expire_status);
P6t8891.t_carinfo_inquiry_call_log(960×1.2s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_inquiry_call_log ADD INDEX idx_record_tim (record_time);
P7t8891.t_vincheck_supervision(192×4.1s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_vincheck_supervision ADD INDEX idx_is_exist_type (is_exist, type);
P8t8891.v_items(333×2.0s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.v_items ADD INDEX idx_id_item_displ (id, item_display_status); ALTER TABLE t8891.t_sele_item_update_plan ADD INDEX idx_status (status); ALTER TABLE t8891.t_sele_item_hidden ADD INDEX idx_item_id_status (item_id, status);
T1Top1(同 P3 对象) 单条最慢 4.9min,user=t8891 t8891.t_carinfo_coupon_activity补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库
T2Top2(同 P3 对象) 单条最慢 4.8min,user=t8891 t8891.t_carinfo_coupon_activity补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库
T3Top3(同 P3 对象) 单条最慢 4.7min,user=t8891 t8891.t_carinfo_coupon_activity补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库

*采集脚本 .agents/scripts/mysql_slow_prod_report.py,中间数据 outputs/slow_report_prod8891_20261101.json;全程只读。*