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/examined | user / server | 慢因分类 |
|---|
| 1 | 8,539.45 | t591_new.sale_market_pk_result | 650,520 / 650,520 | datastream / ZHDX_t591_148 | EXPLAIN 全表扫描/未用索引 |
| 2 | 6,618.60 | t591_new.market_community_agent_bid_record_detail | 21,645 / 4,773,242,535 | bi / ZHDX_t591_148 | 扫描行数远大于返回行数(4,773,242,535/21,645)、索引范围扫描量过大(market_community_agent_bid_record_detail: key=idx_created_at, rows=3,568,860) |
| 3 | 1,830.45 | t591_new.market_voucher_use | 162 / 990,597,945 | bi / ZHDX_t591_148 | 扫描行数远大于返回行数(990,597,945/162) |
| 4 | 1,707.89 | tw591_gateway.verify_log | 8,741,046 / 8,741,046 | databasus_backup / ZHDX_t591_118:3307 | 其他(需结合 SQL 与执行计划人工判断) |
| 5 | 1,535.63 | t591_new.union_stats_event_item_count | 23,316,990 / 23,316,990 | datastream / ZHDX_t591_148 | 索引范围扫描量过大(union_stats_event_item_count: key=PRIMARY, rows=48,420,540) |
| 6 | 1,418.76 | t591_new.union_stats_event_item_count | 11,613,582 / 11,613,582 | datastream / ZHDX_t591_148 | 索引范围扫描量过大(union_stats_event_item_count: key=PRIMARY, rows=63,664,458) |
| 7 | 1,383.86 | t591.ware_picture | 7,195,718 / 7,195,718 | datastream / ZHDX_t591_148 | 索引范围扫描量过大(ware_picture: key=PRIMARY, rows=14,407,634) |
| 8 | 1,375.79 | t591.ware_picture | 7,130,663 / 7,130,663 | datastream / ZHDX_t591_148 | 索引范围扫描量过大(ware_picture: key=PRIMARY, rows=13,785,104) |
| 9 | 1,353.54 | t591.ware_picture | 10,197,331 / 10,197,331 | datastream / ZHDX_t591_148 | 索引范围扫描量过大(ware_picture: key=PRIMARY, rows=21,549,764) |
| 10 | 1,281.04 | t591_new.union_stats_event_item_count | 17,090,332 / 17,090,332 | datastream / ZHDX_t591_148 | 索引范围扫描量过大(union_stats_event_item_count: key=PRIMARY, rows=83,480,374) |
高频慢查询模式(指纹聚合,取样 20,334 条)
按条数 Top5
| # | 模式(指纹摘要) | 条数 | 平均(s) | 累计 | server | user |
|---|
| 1 | select count(*) as aggregate from sale where status = ? and closed = ? and community_id = ? and kind IN (?...) and posttime >= ? /* ms:tw591ms-cdc */; | 3,357 | 1.70 | 1.59h | ZHDX_t591_207 | tw591 |
| 2 | select 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,335 | 2.70 | 1.00h | RDS_IM | hk591 |
| 3 | select 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,119 | 1.70 | 31.7min | ZHDX_t591_207 | tw591 |
| 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 ?; | 836 | 1.24 | 17.3min | ZHDX_t591_181,ZHDX_t591_182 | tw591 |
| 5 | select count(?) as num,streetid from t591.house_rel where status = ? and closed = ? and type = ? and streetid IN (?...) and kind IN (?...) group by streetid; | 521 | 1.18 | 10.3min | ZHDX_t591_137,ZHDX_t591_181,ZHDX_t591_18 | tw591 |
按累计耗时 Top5
| # | 模式 | 条数 | 平均(s) | 累计 | server | user |
|---|
| 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 (id >= ?) AND (NOT (id >= ?)) AND (id IS NOT NULL); | 50 | 674.27 | 9.36h | ZHDX_t591_148 | datastream |
| 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); | 49 | 437.25 | 5.95h | ZHDX_t591_148 | datastream |
| 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 (id >= ?) AND (NOT (id >= ?)) AND (id IS NOT NULL); | 55 | 353.87 | 5.41h | ZHDX_t591_148 | datastream |
| 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); | 49 | 356.92 | 4.86h | ZHDX_t591_148 | datastream |
| 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 (id > ?); | 59 | 286.48 | 4.70h | ZHDX_t591_148 | datastream |
备份模式全天 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);
- 库表:t591.ware_picture;实例 alias:
prod-591/master
- explain SQL:
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);
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | ware_picture | range | PRIMARY | PRIMARY | 14,407,634 | 100.0% |
- 慢因:索引范围扫描量过大(ware_picture: key=PRIMARY, rows=14,407,634)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
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);
- 库表:t591.sale;实例 alias:
prod-591/master
- explain SQL:
SELECT * FROM `t591`.`sale` WHERE `id` >= 6779384 LIMIT 10
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | sale | range | PRIMARY | PRIMARY | 8,794,440 | 100.0% |
- 慢因:索引范围扫描量过大(sale: key=PRIMARY, rows=8,794,440)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
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);
- 库表:t591_new.push_line_history_records;实例 alias:
prod-591/master
- explain SQL:
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);
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | push_line_history_records | range | PRIMARY | PRIMARY | 6,643,004 | 100.0% |
- 慢因:索引范围扫描量过大(push_line_history_records: key=PRIMARY, rows=6,643,004)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
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);
- 库表:t591.rent;实例 alias:
prod-591/master
- explain SQL:
SELECT * FROM `t591`.`rent` WHERE `id` >= 19606611 LIMIT 10
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | rent | range | PRIMARY | PRIMARY | 5,001,762 | 100.0% |
- 慢因:索引范围扫描量过大(rent: key=PRIMARY, rows=5,001,762)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
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);
- 库表:t591_new.union_stats_event_item_count;实例 alias:
prod-591/master
- explain SQL:
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);
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | union_stats_event_item_count | range | PRIMARY | PRIMARY | 48,420,540 | 100.0% |
- 慢因:索引范围扫描量过大(union_stats_event_item_count: key=PRIMARY, rows=48,420,540)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
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);
- 库表:t591.ware_picture;实例 alias:
prod-591/master
- explain SQL:
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);
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | ware_picture | range | PRIMARY | PRIMARY | 14,958,378 | 100.0% |
- 慢因:索引范围扫描量过大(ware_picture: key=PRIMARY, rows=14,958,378)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
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);
- 库表:t591_new.push_line_records;实例 alias:
prod-591/master
- explain SQL:
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);
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | push_line_records | range | PRIMARY | PRIMARY | 1,476,280 | 100.0% |
- 慢因:索引范围扫描量过大(push_line_records: key=PRIMARY, rows=1,476,280)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
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);
- 库表:t591_new.union_stats_event_item_count;实例 alias:
prod-591/master
- explain SQL:
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);
- 执行计划(EXPLAIN 表节点,按 JOIN 顺序):
| # | 表 | 访问类型 | 使用索引 | 候选索引 | 预扫行数 | 过滤后 |
|---|
| 1 | union_stats_event_item_count | range | PRIMARY | PRIMARY | 83,480,374 | 100.0% |
- 慢因:索引范围扫描量过大(union_stats_event_item_count: key=PRIMARY, rows=83,480,374)
- 建议:补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
逐条优化建议汇总
P 行 = 深析模式(指纹聚合,按全天累计耗时降序 P1 最大,是优化主战场);T 行 = 单条耗时 Top3 的一次性慢 SQL(多为 bi/导出查询,治理手段通常是限流/降频/移到从库,而非建索引)。
| 编号 | 对象 | 建议 |
|---|
| P1 | t591.ware_picture(50×674.3s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中 |
| P2 | t591.sale(49×437.3s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中 |
| P3 | t591_new.push_line_history_records(55×353.9s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中 |
| P4 | t591.rent(49×356.9s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中 |
| P5 | t591_new.union_stats_event_item_count(59×286.5s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中 |
| P6 | t591.ware_picture(42×350.9s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中 |
| P7 | t591_new.push_line_records(49×288.3s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中 |
| P8 | t591_new.union_stats_event_item_count(50×270.7s) | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中 |
| T1 | Top1 单条最慢 2.37h,user=datastream t591_new.sale_market_pk_result | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库 |
| T2 | Top2 单条最慢 1.84h,user=bi t591_new.market_community_agent_bid_record_detail | 补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库 |
| T3 | Top3 单条最慢 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;全程只读。*