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

MySQL 慢查询日报(线上 prod591)2026-09-10

统计概览

项目值
统计范围2026-09-10 00:00:00 ~ 23:59:59(Asia/Shanghai)
环境prod-591
慢日志条数(ES mysql-slow_*)33,805 条(指纹聚合取样 21,497 条,覆盖率 64%,超过 2 万条上限截断)
Top10 单条最慢5,671.04 s(user=bi,ZHDX_t591_148)
非备份模式最大累计3.64h(3900 次 × 3.36 s)
备份模式(user 含 backup/databasus_backup)40 条、累计 1.45h(单独标注,不触发深析)
监控巡检类(jmysql/proxysql_monitor 或 information_schema)134 条、累计 2.9min(多为 # Schema: 空导致采集端 _grokparsefailure、无库名;单独标注,不触发深析)
深析模式 explain 成功率5/8(62%)
数据来源ES mysql-slow_*(@timestamp)+ MCP 只读 MySQL(describe_schema/explain)
生成时间2026-09-11 09:43(Asia/Shanghai)

Top10 明细(按单条耗时)

#耗时(s)库.表行数 sent/examineduser / server慢因分类
15,671.04t591_new.market_community_agent_bid_record_detail22,292 / 4,893,931,467bi / ZHDX_t591_148扫描行数远大于返回行数(4,893,931,467/22,292)、索引范围扫描量过大(market_community_agent_bid_record_detail: key=idx_created_at, rows=3,568,860)
24,718.09t591.sale0 / 703,720,447bi / ZHDX_t591_148扫描行数远大于返回行数(703,720,447/0)、IN (SELECT ...) 子查询(易退化为相关子查询逐行执行, 建议改 JOIN/EXISTS)
34,538.09t591.sale1 / 703,720,447bi / ZHDX_t591_148扫描行数远大于返回行数(703,720,447/1)、索引选择性差(activity_plan_money: key=type 扫 7,454,989 行回表后仅剩 0.5%,建议把其余 WHERE 等值列并入复合索引)、DISTINCT/GROUP BY 产生临时表(大范围去重/聚合)、IN (SELECT ...) 子查询(易退化为相关子查询逐行执行, 建议改 JOIN/EXISTS)
42,908.53t591.sale1 / 703,721,042bi / ZHDX_t591_148扫描行数远大于返回行数(703,721,042/1)、索引选择性差(activity_plan_money: key=type 扫 7,454,989 行回表后仅剩 0.5%,建议把其余 WHERE 等值列并入复合索引)、DISTINCT/GROUP BY 产生临时表(大范围去重/聚合)、IN (SELECT ...) 子查询(易退化为相关子查询逐行执行, 建议改 JOIN/EXISTS)
51,687.09tw591_gateway.verify_log8,741,046 / 8,741,046databasus_backup / ZHDX_t591_118:3307其他(需结合 SQL 与执行计划人工判断)
61,450.70t591_new.push_line_records565,487 / 565,487datastream / ZHDX_t591_148索引范围扫描量过大(push_line_records: key=PRIMARY, rows=1,456,882)
71,426.94t591_new.push_line_records565,487 / 565,487datastream / ZHDX_t591_148其他(需结合 SQL 与执行计划人工判断)
81,416.81t591_new.push_line_records565,487 / 565,487datastream / ZHDX_t591_148索引范围扫描量过大(push_line_records: key=PRIMARY, rows=1,017,742)
91,412.27t591_new.push_line_records565,487 / 565,487datastream / ZHDX_t591_148索引范围扫描量过大(push_line_records: key=PRIMARY, rows=10,881,669)
101,412.22t591_new.push_line_records522,726 / 522,726datastream / ZHDX_t591_148其他(需结合 SQL 与执行计划人工判断)

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

按条数 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,9981.711.89hZHDX_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 */3,9003.363.64hRDS_IMhk591
3
select a.community_id, MIN(a.user_id) as user_id from t591.sale as a inner join t591_new.market_community_agent_bid_record as b on a.user_id = b.user_id inner j …(点击展开完整 SQL)
select a.community_id, MIN(a.user_id) as user_id from t591.sale as a inner join t591_new.market_community_agent_bid_record as b on a.user_id = b.user_id inner join t591_new.im_user_bind as im on im.im_uid=CONCAT(a.user_id,?) where a.community_id IN (?...) and b.start_time >= ? and b.end_time <= ? and b.status = ? and b.proc_status = ? and b.deleted = ? and a.status = ? and a.closed = ? group by a.community_id /* ms:tw591ms-community */;
1,9324.802.58hZHDX_t591_137,ZHDX_t591_181,ZHDX_t591_18tw591
4select count(?) as num,streetid from t591.house_rel where status = ? and closed = ? and type = ? and streetid IN (?...) and kind IN (?...) group by streetid;6661.1412.6minZHDX_t591_137,ZHDX_t591_181,ZHDX_t591_18tw591
5
select sum(ivr_call) as aggregate from build_stat_total where theday = ? and cate_id = ? and build_id in (select tupd.hid from t591_new.union_package_detail as …(点击展开完整 SQL)
select sum(ivr_call) as aggregate from build_stat_total where theday = ? and cate_id = ? and build_id in (select tupd.hid from t591_new.union_package_detail as tupd left join t591.build on tupd.hid = build.id where build.regionid IN (?...) and tupd.deleted = ? and tupd.start_time <= ? and tupd.end_time >= ? and (tupd.close = ? or (tupd.close IN (?...) and tupd.close_time > ?))) /* ms:tw591ms-advertising */;
5861.6616.2minZHDX_t591_137,ZHDX_t591_181,ZHDX_t591_18tw591

按累计耗时 Top5

#模式条数平均(s)累计serveruser
1select 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 */3,9003.363.64hRDS_IMhk591
2
select a.community_id, MIN(a.user_id) as user_id from t591.sale as a inner join t591_new.market_community_agent_bid_record as b on a.user_id = b.user_id inner j …(点击展开完整 SQL)
select a.community_id, MIN(a.user_id) as user_id from t591.sale as a inner join t591_new.market_community_agent_bid_record as b on a.user_id = b.user_id inner join t591_new.im_user_bind as im on im.im_uid=CONCAT(a.user_id,?) where a.community_id IN (?...) and b.start_time >= ? and b.end_time <= ? and b.status = ? and b.proc_status = ? and b.deleted = ? and a.status = ? and a.closed = ? group by a.community_id /* ms:tw591ms-community */;
1,9324.802.58hZHDX_t591_137,ZHDX_t591_181,ZHDX_t591_18tw591
3SELECT CURDATE() dt,count(DISTINCT user_id) ?, count(?) ? FROM t591.sale WHERE posttime>=UNIX_TIMESTAMP(?) and closed=? -- and status=? and end_time>=UNIX_TIMESTAMP(?) and user_id IN (?...);23723.312.07hZHDX_t591_148bi
4select count(*) as aggregate from sale where status = ? and closed = ? and community_id = ? and kind IN (?...) and posttime >= ? /* ms:tw591ms-cdc */;3,9981.711.89hZHDX_t591_207tw591
5
SELECT mcrd.id, mcbr.period_id as ?, mcrd.record_id ?, if(mcbr.parent_id!=?,mcbr.parent_id,null) ?, mcrd.oid ?, mcrd.user_id ?, case mcrd.payment_type when ? th …(点击展开完整 SQL)
SELECT mcrd.id, mcbr.period_id as ?, mcrd.record_id ?, if(mcbr.parent_id!=?,mcbr.parent_id,null) ?, mcrd.oid ?, mcrd.user_id ?, case mcrd.payment_type when ? then ? when ? then ? end ?, mcrd.money ?, mcrd. type ?, mcrd.rank ?, mcrd.community_id ?, -- mc.name ?, ar.name ?, ase.name ?, case when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcbr.source=? then ? when mcbr.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source=? then ? when mcrd.source>=? and mcrd.source<=? then ? else mcrd.source end ?, mcrd.deleted ?, -- ,?、為已刪,?、未未刪 case mcrd.pay_status when ? then ? when ? then ? when ? then ? when ? then ? when ? then ? else mcrd.pay_status end ?, mcrd.created_at ?, mcrd.updated_at ? from t591_new.market_community_agent_bid_record_detail mcrd LEFT JOIN t591_new.market_community_agent_bid_record mcbr on mcrd.record_id=mcbr.id and mcrd.user_id=mcbr.user_id LEFT JOIN t591_new.market_community_bid_rules mcr on mcbr.community_id=mcr.community_id -- and mcbr.period_id=mcr.period_id LEFT JOIN t591_new.market_community mc on mcrd.community_id=mc.id left JOIN t591_new.area_region ar on mcr.regionid=ar.id left JOIN t591_new.area_section ase on mcr.sectionid=ase.id LEFT JOIN t591_new.market_community_agent_order mco on mcrd.oid=mco.id LEFT JOIN t591_new.market_voucher_use mvu on mcrd.user_id=mvu.user_id and mcrd.oid=mvu.oid and mvu.oid!=? LEFT join t591_new.market_voucher mv on mvu.voucher_id=mv.id LEFT join t591_new.market_voucher_config mvc on mv.config_id=mvc.id WHERE mcrd.created_at>=? and mcbr.parent_id!=? and (mcrd.created_at>=DATE_SUB(CURDATE(),INTERVAL ? DAY) or mcrd.updated_at>=DATE_SUB(CURDATE(),INTERVAL ? DAY));
15671.041.58hZHDX_t591_148bi
备份模式全天 40 条 / 1.45h,未触发深度分析(如条数环比异常翻倍再人工介入)。

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

1. select last_contacted_at, uid, is_sticked from im_conversations where conversation IN (?...) and uid != ? and im_conversations.deleted_at is null /* ms:hongyan- —— 3,900 次 × 3.36s = 3.64h

select `last_contacted_at`, `uid`, `is_sticked` from `im_conversations` where `conversation` in (select `conversation` from `im_conversations` where `app_id` = '3' and `uid` = '1001' and `deleted_at` is null) and `uid` != '1001' and `im_conversations`.`deleted_at` is null /* ms:hongyan-web-server */
ALTER TABLE `im_conversations` ADD INDEX `idx_app_id_uid_conversati` (`app_id`, `uid`, `conversation`);

2. select a.community_id, MIN(a.user_id) as user_id from t591.sale as a inner join t591_new.market_community_agent_bid_record as b on a.user_id = b.user_id inner j —— 1,932 次 × 4.80s = 2.58h

select a.community_id, MIN(a.user_id) as user_id from t591.sale as a inner join `t591_new`.`market_community_agent_bid_record` as `b` on `a`.`user_id` = `b`.`user_id` inner join `t591_new`.`im_user_bind` as `im` on im.im_uid=CONCAT(a.user_id,"") where `a`.`community_id` in ('105035', '3681594', '49563') and `b`.`start_time` >= '2026-09-10 00:00:00' and `b`.`end_time` <= '2026-09-10 23:59:59' and `b`.`status` = '3' and `b`.`proc_status` = '3' and `b`.`deleted` = '0' and `a`.`status` = '2' and `a`.`closed` = '0' group by `a`.`community_id` /* ms:tw591ms-community */;
select a.community_id, MIN(a.user_id) as user_id from t591.sale as a inner join `t591_new`.`market_community_agent_bid_record` as `b` on `a`.`user_id` = `b`.`user_id` inner join `t591_new`.`im_user_bind` as `im` on im.im_uid=CONCAT(a.user_id,"") where `a`.`community_id` in ('105035', '3681594', '49563') and `b`.`start_time` >= '2026-09-10 00:00:00' and `b`.`end_time` <= '2026-09-10 23:59:59' and `b`.`status` = '3' and `b`.`proc_status` = '3' and `b`.`deleted` = '0' and `a`.`status` = '2' and `a`.`closed` = '0' group by `a`.`community_id` /* ms:tw591ms-community */;
#表访问类型使用索引候选索引预扫行数过滤后
1arangeidx_community_iduser_id,idx_community_id18,6541.0%
2brefidx_user_ididx_user_id,idx_start_end_time4310.01%
3imrefuiduid1100.0%
ALTER TABLE `t591`.`sale` ADD INDEX `idx_status_proc_statu_deleted_closed_community__start_time` (`status`, `proc_status`, `deleted`, `closed`, `community_id`, `start_time`);

3. SELECT CURDATE() dt,count(DISTINCT user_id) ?, count(?) ? FROM t591.sale WHERE posttime>=UNIX_TIMESTAMP(?) and closed=? -- and status=? and end_time>=UNIX_TIMES —— 2 次 × 3723.31s = 2.07h

SELECT CURDATE() dt,count(DISTINCT user_id) '会员数', count(1) '物件数' 
FROM t591.sale 
WHERE posttime>=UNIX_TIMESTAMP('2023-01-01') and `closed`=0 -- and `status`=2
and end_time>=UNIX_TIMESTAMP('2023-07-03') and user_id in (
SELECT DISTINCT user_id from t591.activity_plan_money where `type`=2 and sign=2 and `status`=1 and posttime<UNIX_TIMESTAMP('2023-07-03')
);
SELECT CURDATE() dt,count(DISTINCT user_id) '会员数', count(1) '物件数' 
FROM t591.sale 
WHERE posttime>=UNIX_TIMESTAMP('2023-01-01') and `closed`=0 -- and `status`=2
and end_time>=UNIX_TIMESTAMP('2023-07-03') and user_id in (
SELECT DISTINCT user_id from t591.activity_plan_money where `type`=2 and sign=2 and `status`=1 and posttime<UNIX_TIMESTAMP('2023-07-03')
);
#表访问类型使用索引候选索引预扫行数过滤后
1activity_plan_moneyreftypeuser_id,type,idx_posttime7,454,9950.5%
2salerefuser_iduser_id,posttime551.67%
ALTER TABLE `t591`.`sale` ADD INDEX `idx_closed_status_type_sign_user_id_posttime` (`closed`, `status`, `type`, `sign`, `user_id`, `posttime`);

4. select count(*) as aggregate from sale where status = ? and closed = ? and community_id = ? and kind IN (?...) and posttime >= ? /* ms:tw591ms-cdc */; —— 3,998 次 × 1.71s = 1.89h

select count(*) as aggregate from `sale` where `status` = '2' and `closed` = '0' and `community_id` = '34062' and `kind` in ('6', '8', '9', '10', '24') and `posttime` >= '1787673600' /* ms:tw591ms-cdc */;
SELECT * FROM `t591`.`sale` WHERE `status` = '2' LIMIT 10
#表访问类型使用索引候选索引预扫行数过滤后
1sale❌ 全表扫描——16,844,71310.0%
ALTER TABLE `t591`.`sale` ADD INDEX `idx_status` (`status`);

5. SELECT mcrd.id, mcbr.period_id as ?, mcrd.record_id ?, if(mcbr.parent_id!=?,mcbr.parent_id,null) ?, mcrd.oid ?, mcrd.user_id ?, case mcrd.payment_type when ? th —— 1 次 × 5671.04s = 1.58h

SELECT 
mcrd.`id`,
mcbr.period_id as '期数',
mcrd.`record_id` '竞价ID',
if(mcbr.parent_id!=0,mcbr.parent_id,null) '父竞价ID',
mcrd.oid '订单ID',
mcrd.`user_id` '会员ID',
case mcrd.`payment_type` when 1 then '竞价' when 2 then '调价' end '出价类型',
mcrd.`money` '(出价/调价)金额',
mcrd. `type` '竞价类型',
mcrd.`rank` '预排名',
mcrd.`community_id` '社区ID',
-- mc.`name` '社区名称',
ar.`name` '社区县市',
ase.`name` '社区乡镇',
case when mcrd.`source`=1 then '推荐' when mcrd.`source`=2 then '搜寻' when mcrd.`source`=3 then '收藏' when mcrd.`source`=4 then '上期' 
when mcrd.`source`=5 then '历史' when mcrd.`source`=6 then '续购' when mcrd.`source`=7 then '物件管理页' when mcrd.`source`=8 then '会员中心推荐社区弹窗' when mcrd.`source`=9 then '召集令活动页' when mcrd.`source`=10 then '企业号触屏' when mcrd.`source`=11 then '精准营销弹窗' when mcrd.`source`=12 then '物件刊登成功页' when mcrd.`source`=13 then '物件管理页顶部推荐' when mcrd.`source`=14 then '最新续购' 
when mcrd.`source`=15 then '优质社区推荐'
when mcrd.`source`=16 then '弹窗复购'
when mcrd.`source`=17 then '弹窗續費'
when mcrd.`source`=18 then '中古屋詳情頁PC端'
when mcrd.`source`=19 then '中古屋詳情頁觸屏端'
when mcrd.`source`=20 then '中古屋詳情頁APP端'
when mcrd.`source`=21 then '租屋詳情頁PC端'
when mcrd.`source`=22 then '租屋詳情頁觸屏端'
when mcrd.`source`=23 then '租詳情頁APP端'
when mcrd.`source`=24 then 'PC-会员中心优惠券'
when mcrd.`source`=25 then '触屏-会员中心'
when mcrd.`source`=26 then 'APP-会员中心'
when mcrd.`source`=27 then '四端-金牌专家版位'
when mcrd.`source`=28 then '四端-介绍页'
when mcrd.`source`=29 then '待办事项提醒续费'
when mcrd.`source`=30 then '待办事项体系到期复购'
when mcrd.`source`=31 then 'PC-现金券列表'
when mcrd.`source`=32 then '触屏-现金券列表'
when mcrd.`source`=33 then 'PC-领取成功弹窗社区推荐'
when mcrd.`source`=34 then 'PC-待使用弹窗社区推荐' 
when mcrd.`source`=35 then '物件管理页顶部推荐(物件推荐)'
when mcrd.`source`=37 then '曝光失败弹窗复购'
when mcrd.`source`=38 then '即将到期一键续购'
when mcrd.`source`=39 then '已到期一键续购'
when mcbr.`source`=40 then '即将到期一键续购-触屏'
when mcbr.`source`=41 then '即将到期一键续购-APP'
when mcrd.`source`=101 then '其他'
when mcrd.`source`=102 then 'pc金牌专家购买列表'
when mcrd.`source`=103 then '触屏金牌专家购买列表'
when mcrd.`source`=104 then 'PC物件管理页列表'
when mcrd.`source`=105 then 'PC弹窗引导'
when mcrd.`source`>=100 and mcrd.`source`<=200 then '自定义' else mcrd.`source` end '订单入口来源',
mcrd.`deleted` '是否刪除',  -- ,1、為已刪,0、未未刪
case mcrd.`pay_status` when 1 then '待支付' when 2 then '已支付' when 3 then '退款' when 4 then '取消' when 5 then '失败' else mcrd.`pay_status` end '支付状态',
mcrd.`created_at` '创建时间',
mcrd.`updated_at` '更新时间' 
from t591_new.market_community_agent_bid_record_detail mcrd 
LEFT JOIN t591_new.market_community_agent_bid_record mcbr on mcrd.record_id=mcbr.id and mcrd.user_id=mcbr.user_id 
LEFT JOIN t591_new.market_community_bid_rules mcr on mcbr.`community_id`=mcr.community_id -- and mcbr.period_id=mcr.period_id
LEFT JOIN t591_new.`market_community` mc on mcrd.community_id=mc.id 
left JOIN t591_new.area_region ar on mcr.`regionid`=ar.id
left JOIN t591_new.`area_section` ase on mcr.sectionid=ase.id 
LEFT JOIN t591_new.market_community_agent_order mco on mcrd.oid=mco.id 
LEFT JOIN t591_new.market_voucher_use mvu on mcrd.user_id=mvu.user_id and mcrd.oid=mvu.oid and mvu.oid!=0
LEFT join t591_new.market_voucher mv on mvu.voucher_id=mv.id
LEFT join t591_new.market_voucher_config mvc on mv.config_id=mvc.id 
WHERE mcrd.created_at>='2023-08-21' and mcbr.parent_id!=0
and (mcrd.created_at>=DATE_SUB(CURDATE(),INTERVAL 2 DAY) or mcrd.updated_at>=DATE_SUB(CURDATE(),INTERVAL 2 DAY));
SELECT * FROM `t591_new`.`market_community_agent_bid_record_detail` WHERE created_at>='2023-08-21' LIMIT 10
#表访问类型使用索引候选索引预扫行数过滤后
1market_community_agent_bid_record_detailrangeidx_created_atidx_created_at3,568,860100.0%

6. select * from (SELECT CURDATE() dt,count(DISTINCT user_id) ?, count(?) ? FROM t591.sale WHERE posttime>=UNIX_TIMESTAMP(?) and closed=? -- and status=? and end_t —— 1 次 × 4718.09s = 1.31h

select *
from (SELECT CURDATE() dt,count(DISTINCT user_id) '会员数', count(1) '物件数' 
FROM t591.sale 
WHERE posttime>=UNIX_TIMESTAMP('2023-01-01') and `closed`=0 -- and `status`=2
and end_time>=UNIX_TIMESTAMP('2023-07-03') and user_id in (
SELECT DISTINCT user_id from t591.activity_plan_money where `type`=2 and sign=2 and `status`=1 and posttime<UNIX_TIMESTAMP('2023-07-03')
)
) as `T`
limit 0;
select *
from (SELECT CURDATE() dt,count(DISTINCT user_id) '会员数', count(1) '物件数' 
FROM t591.sale 
WHERE posttime>=UNIX_TIMESTAMP('2023-01-01') and `closed`=0 -- and `status`=2
and end_time>=UNIX_TIMESTAMP('2023-07-03') and user_id in (
SELECT DISTINCT user_id from t591.activity_plan_money where `type`=2 and sign=2 and `status`=1 and posttime<UNIX_TIMESTAMP('2023-07-03')
)
) as `T`
limit 0;
ALTER TABLE `t591`.`sale` ADD INDEX `idx_closed_status_type_sign_user_id_posttime` (`closed`, `status`, `type`, `sign`, `user_id`, `posttime`);

7. select start_time, user_host, query_time, lock_time, rows_sent, rows_examined, db, sql_text from mysql.slow_log WHERE start_time >= DATE_SUB(NOW(), INTERVAL ? M —— 125 次 × 27.27s = 56.8min

select start_time, user_host, query_time, lock_time, rows_sent, rows_examined, db, sql_text from mysql.slow_log WHERE start_time >= DATE_SUB(NOW(), INTERVAL 5 MINUTE) AND start_time <= NOW()
ALTER TABLE `mysql`.`slow_log` ADD INDEX `idx_start_time` (`start_time`);

8. -- name: GetGoldenSourceCommunityIDRepairStreets :many SELECT gs.street_id, COUNT(*) AS golden_source_count FROM golden_source gs JOIN t591_new.market_community —— 180 次 × 11.44s = 34.3min

-- name: GetGoldenSourceCommunityIDRepairStreets :many
SELECT gs.street_id,
       COUNT(*) AS golden_source_count
FROM golden_source gs
         JOIN t591_new.market_community_building cb ON cb.id = gs.community_bid
         JOIN t591_new.market_community c ON c.id = cb.community_id AND c.deleted_at IS NULL
WHERE gs.community_bid != 0
  AND gs.community_id = 0
  AND gs.street_id != 0
  AND gs.type = 1
GROUP BY gs.street_id
ORDER BY gs.street_id
LIMIT 5;
SELECT * FROM `t591_new`.`market_community_building` WHERE community_id = 0 LIMIT 10
#表访问类型使用索引候选索引预扫行数过滤后
1market_community_buildingrefidx_community_ididx_community_id33,124100.0%

逐条优化建议汇总

P 行 = 深析模式(指纹聚合,按全天累计耗时降序 P1 最大,是优化主战场);T 行 = 单条耗时 Top3 的一次性慢 SQL(多为 bi/导出查询,治理手段通常是限流/降频/移到从库,而非建索引)。
编号对象建议
P1?.im_conversations(3,900×3.4s)改写为 JOIN/EXISTS 并验证子查询能下推; 该实例无 MCP 映射, 建议在库上手动 EXPLAIN 复核
P2t591.sale(1,932×4.8s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; 扩复合索引: 把其余 WHERE 等值列追加到现有索引尾部, 避免 10 万+ 行回表; DDL: ALTER TABLE t591.sale ADD INDEX idx_status_proc_statu_deleted_closed_community__start_time (status, proc_status, deleted, closed, community_id, start_time);; JOIN 两侧列改为同类型直连(如int列配int列), 或新增冗余绑定列建索引
P3t591.sale(2×3723.3s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; 扩复合索引: 把其余 WHERE 等值列追加到现有索引尾部, 避免 10 万+ 行回表; DDL: ALTER TABLE t591.sale ADD INDEX idx_closed_status_type_sign_user_id_posttime (closed, status, type, sign, user_id, posttime);; 缩小聚合/去重范围(补时间等过滤条件), 或预聚合到中间表/定时任务; 改写为 JOIN/EXISTS 并验证子查询能下推; 该实例无 MCP 映射, 建议在库上手动 EXPLAIN 复核
P4t591.sale(3,998×1.7s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t591.sale ADD INDEX idx_status (status);
P5t591_new.market_community_agent_bid_record_detail(1×5671.0s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
P6t591.sale(1×4718.1s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t591.sale ADD INDEX idx_closed_status_type_sign_user_id_posttime (closed, status, type, sign, user_id, posttime);; 改写为 JOIN/EXISTS 并验证子查询能下推; 该实例无 MCP 映射, 建议在库上手动 EXPLAIN 复核
P7mysql.slow_log(125×27.3s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE mysql.slow_log ADD INDEX idx_start_time (start_time);
P8t591_new.market_community_building(180×11.4s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
T1Top1(同 P5 对象) 单条最慢 1.58h,user=bi t591_new.market_community_agent_bid_record_detail补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库
T2Top2(同 P6 对象) 单条最慢 1.31h,user=bi t591.sale补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t591.sale ADD INDEX idx_closed_status_type_sign_user_id_posttime (closed, status, type, sign, user_id, posttime);; 改写为 JOIN/EXISTS 并验证子查询能下推; 该实例无 MCP 映射, 建议在库上手动 EXPLAIN 复核; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库
T3Top3(同 P6 对象) 单条最慢 1.26h,user=bi t591.sale补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; 扩复合索引: 把其余 WHERE 等值列追加到现有索引尾部, 避免 10 万+ 行回表; DDL: ALTER TABLE t591.sale ADD INDEX idx_closed_status_type_sign_user_id_posttime (closed, status, type, sign, user_id, posttime);; 缩小聚合/去重范围(补时间等过滤条件), 或预聚合到中间表/定时任务; 改写为 JOIN/EXISTS 并验证子查询能下推; 该实例无 MCP 映射, 建议在库上手动 EXPLAIN 复核; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库

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