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

MySQL 慢查询日报(线上 prod591)2026-11-03

统计概览

项目值
统计范围2026-11-03 00:00:00 ~ 23:59:59(Asia/Shanghai)
环境prod-591
慢日志条数(ES mysql-slow_*)35,095 条(指纹聚合取样 20,334 条,覆盖率 58%,超过 2 万条上限截断)
Top10 单条最慢8,539.45 s(user=datastream,ZHDX_t591_148)
非备份模式最大累计9.36h(50 次 × 674.27 s)
备份模式(user 含 backup/databasus_backup)47 条、累计 1.53h(单独标注,不触发深析)
监控巡检类(jmysql/proxysql_monitor 或 information_schema)77 条、累计 1.6min(多为 # Schema: 空导致采集端 _grokparsefailure、无库名;单独标注,不触发深析)
深析模式 explain 成功率8/8(100%)
数据来源ES mysql-slow_*(@timestamp)+ MCP 只读 MySQL(describe_schema/explain)
生成时间2026-11-04 09:43(Asia/Shanghai)

Top10 明细(按单条耗时)

#耗时(s)库.表行数 sent/examineduser / server慢因分类
18,539.45t591_new.sale_market_pk_result650,520 / 650,520datastream / ZHDX_t591_148EXPLAIN 全表扫描/未用索引
26,618.60t591_new.market_community_agent_bid_record_detail21,645 / 4,773,242,535bi / ZHDX_t591_148扫描行数远大于返回行数(4,773,242,535/21,645)、索引范围扫描量过大(market_community_agent_bid_record_detail: key=idx_created_at, rows=3,568,860)
31,830.45t591_new.market_voucher_use162 / 990,597,945bi / ZHDX_t591_148扫描行数远大于返回行数(990,597,945/162)
41,707.89tw591_gateway.verify_log8,741,046 / 8,741,046databasus_backup / ZHDX_t591_118:3307其他(需结合 SQL 与执行计划人工判断)
51,535.63t591_new.union_stats_event_item_count23,316,990 / 23,316,990datastream / ZHDX_t591_148索引范围扫描量过大(union_stats_event_item_count: key=PRIMARY, rows=48,420,540)
61,418.76t591_new.union_stats_event_item_count11,613,582 / 11,613,582datastream / ZHDX_t591_148索引范围扫描量过大(union_stats_event_item_count: key=PRIMARY, rows=63,664,458)
71,383.86t591.ware_picture7,195,718 / 7,195,718datastream / ZHDX_t591_148索引范围扫描量过大(ware_picture: key=PRIMARY, rows=14,407,634)
81,375.79t591.ware_picture7,130,663 / 7,130,663datastream / ZHDX_t591_148索引范围扫描量过大(ware_picture: key=PRIMARY, rows=13,785,104)
91,353.54t591.ware_picture10,197,331 / 10,197,331datastream / ZHDX_t591_148索引范围扫描量过大(ware_picture: key=PRIMARY, rows=21,549,764)
101,281.04t591_new.union_stats_event_item_count17,090,332 / 17,090,332datastream / ZHDX_t591_148索引范围扫描量过大(union_stats_event_item_count: key=PRIMARY, rows=83,480,374)

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

按条数 Top5

#模式(指纹摘要)条数平均(s)累计serveruser
1select count(*) as aggregate from sale where status = ? and closed = ? and community_id = ? and kind IN (?...) and posttime >= ? /* ms:tw591ms-cdc */;3,3571.701.59hZHDX_t591_207tw591
2select last_contacted_at, uid, is_sticked from im_conversations where conversation IN (?...) and uid != ? and im_conversations.deleted_at is null /* ms:hongyan-web-server */1,3352.701.00hRDS_IMhk591
3select id, name, checkstatus, deleted, build_purpose from t591_new.market_community FORCE INDEX(idx_region_section) where status = ? and deleted = ? and checkstatus = ? and type = ? and regionid = ? and sectionid = ? /* ms:tw591ms-cdc */;1,1191.7031.7minZHDX_t591_207tw591
4
select orign.id, orign.start_time, u.the_id as build_id, orign.status, orign.hangup_cause from t591_ivr.ivr_ext_service_call_t591 as orign left join t591_ivr.iv …(点击展开完整 SQL)
select orign.id, orign.start_time, u.the_id as build_id, orign.status, orign.hangup_cause from t591_ivr.ivr_ext_service_call_t591 as orign left join t591_ivr.ivr_ext_usr_number as u on orign.number = u.number and u.the_type = ? where orign.project_idc = ? AND u.the_type = ? AND orign.start_time >= ? AND orign.start_time <= ? and orign.id > ? order by orign.id asc limit ?;
8361.2417.3minZHDX_t591_181,ZHDX_t591_182tw591
5select count(?) as num,streetid from t591.house_rel where status = ? and closed = ? and type = ? and streetid IN (?...) and kind IN (?...) group by streetid;5211.1810.3minZHDX_t591_137,ZHDX_t591_181,ZHDX_t591_18tw591

按累计耗时 Top5

#模式条数平均(s)累计serveruser
1SELECT id, user_id, type, post_id, path, filename, posttime, cate_id, kind_id, closed, is_cover, add_val, layout_val, note, purpose FROM t591.ware_picture WHERE (id >= ?) AND (NOT (id >= ?)) AND (id IS NOT NULL);50674.279.36hZHDX_t591_148datastream
2
SELECT id, user_id, regionid, sectionid, streetid, street_name, address, cases_id, community_id, saletype, room, hall, toilet, balcony, price, area, feet, area_ …(点击展开完整 SQL)
SELECT id, user_id, regionid, sectionid, streetid, street_name, address, cases_id, community_id, saletype, room, hall, toilet, balcony, price, area, feet, area_unit, groundtype, groundkind, groundarea, floor, allfloor, kind, shape, housetype, warnmsg, isrecmoney, recmoney, linkman, is_entrust, email, mobile, phone, fitment, living, pubarea, trabus, tratrain, tragoods, houseage, houseage_month, manage, direction, cartplace, cartplacetype, carttype, cartmodel, cartowner, car_money, car_area, lift, isrenting, houseclass, mainarea, buildaddons, payway, firstpay, buildmaterial, spacematerial, buildmaterial_other, spacematerial_other, manageprice_period, manageprice, posttime, start_time, end_time, updatetime, refreshtime, ispay, agency_id, gmid, houseimg, maxhouseimg, houseimg_kind, maxhouseimg_kind, hasimg, status, closed, checkstatus, browsenum, comment_total, comment_unread, comment_ltime, lmsets, remark, isvip, mvip, repost, cover, alley, lane, addr_number, addr_number2, room_num, hide_addr_detail, balcony_area, rain_area, house_area, manage_type, cometime, CAST(CONVERT_TZ(ltime, @@session.time_zone, ?) AS DATETIME(?)) AS ltime, purpose, addarea, purpose_text, house_build_date, first_payment_ratio, un_mortgage FROM t591.sale WHERE (id >= ?) AND (NOT (id >= ?)) AND (id IS NOT NULL);
49437.255.95hZHDX_t591_148datastream
3SELECT id, rid, type, post_id, status, ware_type, search_type, housing_union_type, click, created_at, updated_at FROM t591_new.push_line_history_records WHERE (id >= ?) AND (NOT (id >= ?)) AND (id IS NOT NULL);55353.875.41hZHDX_t591_148datastream
4
SELECT id, user_id, regionid, sectionid, streetid, street_name, address, cases_id, postshow, room, hall, toilet, balcony, price, area, feet, area_unit, groundty …(点击展开完整 SQL)
SELECT id, user_id, regionid, sectionid, streetid, street_name, address, cases_id, postshow, room, hall, toilet, balcony, price, area, feet, area_unit, groundtype, groundkind, floor, allfloor, kind, shape, housetype, warnmsg, isrecmoney, recmoney, linkman, is_entrust, email, mobile, phone, fitment, deposit_type, deposit, cometime, houseage, houseage_month, house_age_unknown, isleastrent, leastrent, manage, manageprice, spacematerial, spacematerial_other, direction, cartplace, cartplacetype, carttype, cartmodel, cartowner, car_area, lift, cook, pet, sex, degree, toglandlord, living, fixture, hometools, trabus, tratrain, tragoods, posttime, start_time, end_time, updatetime, refreshtime, ispay, agency_id, gmid, hasimg, houseimg, maxhouseimg, houseimg_kind, maxhouseimg_kind, status, closed, checkstatus, browsenum, comment_total, comment_unread, comment_ltime, lmsets, priceadd, remark, isvip, mvip, repost, cover, alley, lane, addr_number, hide_addr_detail, floor_in_floor, lease_type, lease_time, lease_timetype, manage_type, space_type, space_type_other, space_shape, space_shape_other, space_area, space_person, space_floor, space_car, space_price, space_place, space_place_other, space_device, space_leisure, space_leisure_other, CAST(CONVERT_TZ(ltime, @@session.time_zone, ?) AS DATETIME(?)) AS ltime, purpose, area_right, purpose_text, house_build_date FROM t591.rent WHERE (id >= ?) AND (NOT (id >= ?)) AND (id IS NOT NULL);
49356.924.86hZHDX_t591_148datastream
5SELECT id, event_item_id, time, pv, uv, pv_time, uv_time FROM t591_new.union_stats_event_item_count WHERE (id >= ?) AND (NOT (id >= ?)) AND (id IS NOT NULL) AND (id > ?);59286.484.70hZHDX_t591_148datastream
备份模式全天 47 条 / 1.53h,未触发深度分析(如条数环比异常翻倍再人工介入)。

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

1. SELECT id, user_id, type, post_id, path, filename, posttime, cate_id, kind_id, closed, is_cover, add_val, layout_val, note, purpose FROM t591.ware_picture WHERE —— 50 次 × 674.27s = 9.36h

SELECT `id`, `user_id`, `type`, `post_id`, `path`, `filename`, `posttime`, `cate_id`, `kind_id`, `closed`, `is_cover`, `add_val`, `layout_val`, `note`, `purpose` FROM `t591`.`ware_picture` WHERE (`id` >= 193748561) AND (NOT (`id` >= 203945849)) AND (`id` IS NOT NULL);
SELECT `id`, `user_id`, `type`, `post_id`, `path`, `filename`, `posttime`, `cate_id`, `kind_id`, `closed`, `is_cover`, `add_val`, `layout_val`, `note`, `purpose` FROM `t591`.`ware_picture` WHERE (`id` >= 193748561) AND (NOT (`id` >= 203945849)) AND (`id` IS NOT NULL);
#表访问类型使用索引候选索引预扫行数过滤后
1ware_picturerangePRIMARYPRIMARY14,407,634100.0%

2. SELECT id, user_id, regionid, sectionid, streetid, street_name, address, cases_id, community_id, saletype, room, hall, toilet, balcony, price, area, feet, area_ —— 49 次 × 437.25s = 5.95h

SELECT `id`, `user_id`, `regionid`, `sectionid`, `streetid`, `street_name`, `address`, `cases_id`, `community_id`, `saletype`, `room`, `hall`, `toilet`, `balcony`, `price`, `area`, `feet`, `area_unit`, `groundtype`, `groundkind`, `groundarea`, `floor`, `allfloor`, `kind`, `shape`, `housetype`, `warnmsg`, `isrecmoney`, `recmoney`, `linkman`, `is_entrust`, `email`, `mobile`, `phone`, `fitment`, `living`, `pubarea`, `trabus`, `tratrain`, `tragoods`, `houseage`, `houseage_month`, `manage`, `direction`, `cartplace`, `cartplacetype`, `carttype`, `cartmodel`, `cartowner`, `car_money`, `car_area`, `lift`, `isrenting`, `houseclass`, `mainarea`, `buildaddons`, `payway`, `firstpay`, `buildmaterial`, `spacematerial`, `buildmaterial_other`, `spacematerial_other`, `manageprice_period`, `manageprice`, `posttime`, `start_time`, `end_time`, `updatetime`, `refreshtime`, `ispay`, `agency_id`, `gmid`, `houseimg`, `maxhouseimg`, `houseimg_kind`, `maxhouseimg_kind`, `hasimg`, `status`, `closed`, `checkstatus`, `browsenum`, `comment_total`, `comment_unread`, `comment_ltime`, `lmsets`, `remark`, `isvip`, `mvip`, `repost`, `cover`, `alley`, `lane`, `addr_number`, `addr_number2`, `room_num`, `hide_addr_detail`, `balcony_area`, `rain_area`, `house_area`, `manage_type`, `cometime`, CAST(CONVERT_TZ(`ltime`, @@session.time_zone, '+00:00') AS DATETIME(6)) AS `ltime`, `purpose`, `addarea`, `purpose_text`, `house_build_date`, `first_payment_ratio`, `un_mortgage` FROM `t591`.`sale` WHERE (`id` >= 6779384) AND (NOT (`id` >= 7203033)) AND (`id` IS NOT NULL);
SELECT * FROM `t591`.`sale` WHERE `id` >= 6779384 LIMIT 10
#表访问类型使用索引候选索引预扫行数过滤后
1salerangePRIMARYPRIMARY8,794,440100.0%

3. SELECT id, rid, type, post_id, status, ware_type, search_type, housing_union_type, click, created_at, updated_at FROM t591_new.push_line_history_records WHERE ( —— 55 次 × 353.87s = 5.41h

SELECT `id`, `rid`, `type`, `post_id`, `status`, `ware_type`, `search_type`, `housing_union_type`, `click`, `created_at`, `updated_at` FROM `t591_new`.`push_line_history_records` WHERE (`id` >= 46992169) AND (NOT (`id` >= 50908183)) AND (`id` IS NOT NULL);
SELECT `id`, `rid`, `type`, `post_id`, `status`, `ware_type`, `search_type`, `housing_union_type`, `click`, `created_at`, `updated_at` FROM `t591_new`.`push_line_history_records` WHERE (`id` >= 46992169) AND (NOT (`id` >= 50908183)) AND (`id` IS NOT NULL);
#表访问类型使用索引候选索引预扫行数过滤后
1push_line_history_recordsrangePRIMARYPRIMARY6,643,004100.0%

4. SELECT id, user_id, regionid, sectionid, streetid, street_name, address, cases_id, postshow, room, hall, toilet, balcony, price, area, feet, area_unit, groundty —— 49 次 × 356.92s = 4.86h

SELECT `id`, `user_id`, `regionid`, `sectionid`, `streetid`, `street_name`, `address`, `cases_id`, `postshow`, `room`, `hall`, `toilet`, `balcony`, `price`, `area`, `feet`, `area_unit`, `groundtype`, `groundkind`, `floor`, `allfloor`, `kind`, `shape`, `housetype`, `warnmsg`, `isrecmoney`, `recmoney`, `linkman`, `is_entrust`, `email`, `mobile`, `phone`, `fitment`, `deposit_type`, `deposit`, `cometime`, `houseage`, `houseage_month`, `house_age_unknown`, `isleastrent`, `leastrent`, `manage`, `manageprice`, `spacematerial`, `spacematerial_other`, `direction`, `cartplace`, `cartplacetype`, `carttype`, `cartmodel`, `cartowner`, `car_area`, `lift`, `cook`, `pet`, `sex`, `degree`, `toglandlord`, `living`, `fixture`, `hometools`, `trabus`, `tratrain`, `tragoods`, `posttime`, `start_time`, `end_time`, `updatetime`, `refreshtime`, `ispay`, `agency_id`, `gmid`, `hasimg`, `houseimg`, `maxhouseimg`, `houseimg_kind`, `maxhouseimg_kind`, `status`, `closed`, `checkstatus`, `browsenum`, `comment_total`, `comment_unread`, `comment_ltime`, `lmsets`, `priceadd`, `remark`, `isvip`, `mvip`, `repost`, `cover`, `alley`, `lane`, `addr_number`, `hide_addr_detail`, `floor_in_floor`, `lease_type`, `lease_time`, `lease_timetype`, `manage_type`, `space_type`, `space_type_other`, `space_shape`, `space_shape_other`, `space_area`, `space_person`, `space_floor`, `space_car`, `space_price`, `space_place`, `space_place_other`, `space_device`, `space_leisure`, `space_leisure_other`, CAST(CONVERT_TZ(`ltime`, @@session.time_zone, '+00:00') AS DATETIME(6)) AS `ltime`, `purpose`, `area_right`, `purpose_text`, `house_build_date` FROM `t591`.`rent` WHERE (`id` >= 19606611) AND (NOT (`id` >= 20052193)) AND (`id` IS NOT NULL);
SELECT * FROM `t591`.`rent` WHERE `id` >= 19606611 LIMIT 10
#表访问类型使用索引候选索引预扫行数过滤后
1rentrangePRIMARYPRIMARY5,001,762100.0%

5. SELECT id, event_item_id, time, pv, uv, pv_time, uv_time FROM t591_new.union_stats_event_item_count WHERE (id >= ?) AND (NOT (id >= ?)) AND (id IS NOT NULL) AND —— 59 次 × 286.48s = 4.70h

SELECT `id`, `event_item_id`, `time`, `pv`, `uv`, `pv_time`, `uv_time` FROM `t591_new`.`union_stats_event_item_count` WHERE (`id` >= 2275365868) AND (NOT (`id` >= 2316307033)) AND (`id` IS NOT NULL) AND (`id` > 2292989820);
SELECT `id`, `event_item_id`, `time`, `pv`, `uv`, `pv_time`, `uv_time` FROM `t591_new`.`union_stats_event_item_count` WHERE (`id` >= 2275365868) AND (NOT (`id` >= 2316307033)) AND (`id` IS NOT NULL) AND (`id` > 2292989820);
#表访问类型使用索引候选索引预扫行数过滤后
1union_stats_event_item_countrangePRIMARYPRIMARY48,420,540100.0%

6. SELECT id, user_id, type, post_id, path, filename, posttime, cate_id, kind_id, closed, is_cover, add_val, layout_val, note, purpose FROM t591.ware_picture WHERE —— 42 次 × 350.85s = 4.09h

SELECT `id`, `user_id`, `type`, `post_id`, `path`, `filename`, `posttime`, `cate_id`, `kind_id`, `closed`, `is_cover`, `add_val`, `layout_val`, `note`, `purpose` FROM `t591`.`ware_picture` WHERE (`id` >= 346707881) AND (NOT (`id` >= 356905169)) AND (`id` IS NOT NULL) AND (`id` > 348979592);
SELECT `id`, `user_id`, `type`, `post_id`, `path`, `filename`, `posttime`, `cate_id`, `kind_id`, `closed`, `is_cover`, `add_val`, `layout_val`, `note`, `purpose` FROM `t591`.`ware_picture` WHERE (`id` >= 346707881) AND (NOT (`id` >= 356905169)) AND (`id` IS NOT NULL) AND (`id` > 348979592);
#表访问类型使用索引候选索引预扫行数过滤后
1ware_picturerangePRIMARYPRIMARY14,958,378100.0%

7. SELECT id, pid, vid, official, line_id, user_id, payload, plan_time, status, created_at, updated_at, push_type, business_type, business_id, delivery_id, user_le —— 49 次 × 288.33s = 3.92h

SELECT `id`, `pid`, `vid`, `official`, `line_id`, `user_id`, `payload`, `plan_time`, `status`, `created_at`, `updated_at`, `push_type`, `business_type`, `business_id`, `delivery_id`, `user_level` FROM `t591_new`.`push_line_records` WHERE (`id` >= 22217581) AND (NOT (`id` >= 22890841)) AND (`id` IS NOT NULL);
SELECT `id`, `pid`, `vid`, `official`, `line_id`, `user_id`, `payload`, `plan_time`, `status`, `created_at`, `updated_at`, `push_type`, `business_type`, `business_id`, `delivery_id`, `user_level` FROM `t591_new`.`push_line_records` WHERE (`id` >= 22217581) AND (NOT (`id` >= 22890841)) AND (`id` IS NOT NULL);
#表访问类型使用索引候选索引预扫行数过滤后
1push_line_recordsrangePRIMARYPRIMARY1,476,280100.0%

8. SELECT id, event_item_id, time, pv, uv, pv_time, uv_time FROM t591_new.union_stats_event_item_count WHERE (id >= ?) AND (NOT (id >= ?)) AND (id IS NOT NULL); —— 50 次 × 270.66s = 3.76h

SELECT `id`, `event_item_id`, `time`, `pv`, `uv`, `pv_time`, `uv_time` FROM `t591_new`.`union_stats_event_item_count` WHERE (`id` >= 2316307033) AND (NOT (`id` >= 2357248198)) AND (`id` IS NOT NULL);
SELECT `id`, `event_item_id`, `time`, `pv`, `uv`, `pv_time`, `uv_time` FROM `t591_new`.`union_stats_event_item_count` WHERE (`id` >= 2316307033) AND (NOT (`id` >= 2357248198)) AND (`id` IS NOT NULL);
#表访问类型使用索引候选索引预扫行数过滤后
1union_stats_event_item_countrangePRIMARYPRIMARY83,480,374100.0%

逐条优化建议汇总

P 行 = 深析模式(指纹聚合,按全天累计耗时降序 P1 最大,是优化主战场);T 行 = 单条耗时 Top3 的一次性慢 SQL(多为 bi/导出查询,治理手段通常是限流/降频/移到从库,而非建索引)。
编号对象建议
P1t591.ware_picture(50×674.3s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
P2t591.sale(49×437.3s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
P3t591_new.push_line_history_records(55×353.9s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
P4t591.rent(49×356.9s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
P5t591_new.union_stats_event_item_count(59×286.5s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
P6t591.ware_picture(42×350.9s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
P7t591_new.push_line_records(49×288.3s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
P8t591_new.union_stats_event_item_count(50×270.7s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
T1Top1 单条最慢 2.37h,user=datastream t591_new.sale_market_pk_result补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库
T2Top2 单条最慢 1.84h,user=bi t591_new.market_community_agent_bid_record_detail补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库
T3Top3 单条最慢 30.5min,user=bi t591_new.market_voucher_use补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库

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