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

MySQL 慢查询日报(线上 prod8891)2026-10-26

统计概览

项目值
统计范围2026-10-26 00:00:00 ~ 23:59:59(Asia/Shanghai)
环境prod-8891
慢日志条数(ES mysql-slow_*)17,497 条(指纹聚合取样 17,497 条)
Top10 单条最慢288.55 s(user=t8891,YCJF_t8891_25_3307)
非备份模式最大累计5.37h(3499 次 × 5.53 s)
备份模式(user 含 backup/databasus_backup)1 条、累计 1.1s(单独标注,不触发深析)
深析模式 explain 成功率8/8(100%)
数据来源ES mysql-slow_*(@timestamp)+ MCP 只读 MySQL(describe_schema/explain)
生成时间2026-10-27 09:31(Asia/Shanghai)

Top10 明细(按单条耗时)

#耗时(s)库.表行数 sent/examineduser / server慢因分类
1288.55t8891.t_carinfo_coupon_activity2,088 / 655,375t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(655,375/2,088)
2286.30t8891.t_carinfo_coupon_activity2,088 / 655,066t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(655,066/2,088)
3285.15t8891.t_carinfo_coupon_activity2,089 / 655,068t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(655,068/2,089)
4284.46t8891.t_carinfo_coupon_activity2,089 / 655,080t8891 / YCJF_t8891_25扫描行数远大于返回行数(655,080/2,089)
5284.00t8891.t_carinfo_coupon_activity2,089 / 655,068t8891 / YCJF_t8891_25_3307扫描行数远大于返回行数(655,068/2,089)
6282.54t8891.t_carinfo_coupon_activity2,089 / 655,068t8891 / YCJF_t8891_25扫描行数远大于返回行数(655,068/2,089)
7282.46t8891.t_carinfo_coupon_activity2,089 / 655,068t8891 / YCJF_t8891_25扫描行数远大于返回行数(655,068/2,089)
8280.52t8891.t_carinfo_coupon_activity2,089 / 655,068t8891 / YCJF_t8891_25扫描行数远大于返回行数(655,068/2,089)
9280.18t8891.t_carinfo_coupon_activity2,088 / 655,066t8891 / YCJF_t8891_25扫描行数远大于返回行数(655,066/2,088)
10280.15t8891.t_carinfo_coupon_activity2,089 / 655,083t8891 / YCJF_t8891_25扫描行数远大于返回行数(655,083/2,089)

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

按条数 Top5

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

按累计耗时 Top5

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

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

1. select * from t_member_devices where (m_id = ? and hash = ?) limit ?; —— 3,499 次 × 5.53s = 5.37h

select * from `t_member_devices` where (`m_id` = 342660 and `hash` = 'c04d4e771479599129b490fff231f33d') limit 1;
select * from `t8891`.`t_member_devices` where (`m_id` = 342660 and `hash` = 'c04d4e771479599129b490fff231f33d') limit 1;
#表访问类型使用索引候选索引预扫行数过滤后
1t_member_devicesreft_member_devices_m_id_indext_member_devices_m_id_index800,28910.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,257 次 × 5.01s = 1.75h

select f_id, COUNT(*) count from `t_carinfo_favorite` where `m_id` in (0, 169279, 251676, 288473, 294835, 296669, 320024, 351813, 370356, 380628, 449828, 501229, 512899, 525784, 543815, 582688, 597340, 657692, 687281, 693560, 796022, 995008, 1050721, 1050874, 1064576, 1169760, 1178904, 1233049, 1276612, 1297787, 1299074, 1305638, 1306541, 1314860, 1320840, 1325476, 1337531, 1344576, 1363358, 1376615, 1380403, 1403135, 1495147, 1512738, 1517888, 1607279) 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;
select f_id, COUNT(*) count from `t8891`.`t_carinfo_favorite` where `m_id` in (0, 169279, 251676, 288473, 294835, 296669, 320024, 351813, 370356, 380628, 449828, 501229, 512899, 525784, 543815, 582688, 597340, 657692, 687281, 693560, 796022, 995008, 1050721, 1050874, 1064576, 1169760, 1178904, 1233049, 1276612, 1297787, 1299074, 1305638, 1306541, 1314860, 1320840, 1325476, 1337531, 1344576, 1363358, 1376615, 1380403, 1403135, 1495147, 1512738, 1517888, 1607279) and `type` = 3 and exists (select * from `t8891`.`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;
#表访问类型使用索引候选索引预扫行数过滤后
1t_carinfo_favoritereftypem_id,f_id,type,m_id_type570,71950.35%
ALTER TABLE `t8891`.`t_carinfo_favorite` ADD INDEX `idx_type_sale_stop_m_id_count` (`type`, `sale_stop`, `m_id`, `count`);

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 —— 18 次 × 279.31s = 1.40h

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,70750.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 <= ?; —— 1,440 次 × 1.97s = 47.3min

select * from `t_carinfo_inquiry_agent` where `expire_status` = 0 and `expire_time` <= '2026-10-25 23:51:09';
select * from `t8891`.`t_carinfo_inquiry_agent` where `expire_status` = 0 and `expire_time` <= '2026-10-25 23:51:09';
#表访问类型使用索引候选索引预扫行数过滤后
1t_carinfo_inquiry_agent❌ 全表扫描——1,898,7213.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 = ?; —— 1,213 次 × 1.95s = 39.3min

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,7211.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; —— 1,436 次 × 1.36s = 32.6min

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 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 —— 486 次 × 2.02s = 16.4min

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:59:09' and '18:00: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:59:09' and '18:00:08') and `t_sele_item_hidden`.`id` is null;
#表访问类型使用索引候选索引预扫行数过滤后
1t_sele_item_update_plan❌ 全表扫描—PRIMARY,idx_item_id_status315,86110.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`);

8. select t_vincheck_supervision.* from t_vincheck_supervision left join t_vincheck_supervision_info on t_vincheck_supervision_info.vincheck_supervision_id = t_vin —— 225 次 × 3.92s = 14.7min

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,15750.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`);

逐条优化建议汇总

P 行 = 深析模式(指纹聚合,按全天累计耗时降序 P1 最大,是优化主战场);T 行 = 单条耗时 Top3 的一次性慢 SQL(多为 bi/导出查询,治理手段通常是限流/降频/移到从库,而非建索引)。
编号对象建议
P1t8891.t_member_devices(3,499×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,257×5.0s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_favorite ADD INDEX idx_type_sale_stop_m_id_count (type, sale_stop, m_id, count);; 缩小聚合/去重范围(补时间等过滤条件), 或预聚合到中间表/定时任务; 把 ORDER BY 列纳入复合索引, 或减小排序前扫描范围
P3t8891.t_carinfo_coupon_activity(18×279.3s)补索引(按 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(1,440×2.0s)补索引(按 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(1,213×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(1,436×1.4s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_carinfo_inquiry_call_log ADD INDEX idx_record_tim (record_time);
P7t8891.v_items(486×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);
P8t8891.t_vincheck_supervision(225×3.9s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8891.t_vincheck_supervision ADD INDEX idx_is_exist_type (is_exist, type);
T1Top1(同 P3 对象) 单条最慢 4.8min,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.8min,user=t8891 t8891.t_carinfo_coupon_activity补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库

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