| 项目 | 数值 |
|---|---|
| 统计时间范围 | 2026-09-09 00:00:00 ~ 23:59:59(Asia/Shanghai,UTC 换算 [2026-09-08T16:00Z, 2026-09-09T16:00Z)) |
| 慢查询总数 | 118,861 条 |
| ├ 591 集群 | 31,172 条 |
| ├ 8591 集群 | 66,719 条 |
| └ 8891 集群 | 20,970 条 |
| 明细抽样(指纹聚合用) | 59,026 条(每集群最多 4 页 × 5000) |
| SQL 指纹数 | 2,342 个 |
| Top10 单条最大耗时 | 5,711 秒(约 95 分钟) |
| 锁等待型慢查询 | 0 条(Top10 的 Lock_time 均 < 0.1s,占比可忽略) |
| 最大单模式累计耗时 | 20,073 秒(约 5.6 小时)(t8891.t_member_devices 指纹) |
⚠️ staging 环境数据缺失说明:staging ES(elasticsearch-master.es.svc.cluster.local:9200)API Key 认证失败(HTTP 401 invalid credentials),昨日与前日均无法取数。本次日报基于线上三套 ES(prod-591 / prod-8591 / prod-8891,索引mysql-slow_2026.09)合并分析。建议更新 MCP config.yaml 中 es.staging 的 api_key。
| # | 耗时 | 集群/实例 | 用户 | 库.表 | 扫描行数 | 返回行数 | SQL 摘要 | 慢因类型 |
|---|---|---|---|---|---|---|---|---|
| 1 | 5711.5s | 591 / ZHDX_t591_148 | bi | t591 竞价相关多表 | 46.3 亿 | 21,367 | 竞价记录 BI 报表(mcrd/mcbr/ar/ase 多表 JOIN) | 大 JOIN 扫描(缺索引) |
| 2 | 4954.2s | 591 / ZHDX_t591_148 | bi | t591.sale | 7.04 亿 | 0 | 售房物件数/会员数日报(子查询 + DISTINCT,EXPLAIN 超时) | 大范围聚合扫描 |
| 3 | 4796.9s | 8591 / ZHDX_t8591_107 | bi | a8591.t8_mall_stat | 3.23 亿 | 1.61 亿 | SELECT * FROM t8_mall_stat ORDER BY created_at DESC | 全表扫描 + 大结果集传输 |
| 4 | 4774.2s | 591 / ZHDX_t591_148 | bi | t591.sale + activity_plan_money | 7.04 亿 | 1 | 同 #2(活动口径) | 大范围聚合扫描 |
| 5 | 3836.8s | 8591 / ZHDX_t8591_107 | bi | a8591.t8_mall_stat | 3.23 亿 | 1.62 亿 | 同 #3 | 全表扫描 + 大结果集传输 |
| 6 | 3075.5s | 591 / ZHDX_t591_148 | bi | t591.sale + activity_plan_money | 7.04 亿 | 1 | 同 #4 | 大范围聚合扫描 |
| 7 | 3018.9s | 8591 / ZHDX_t8591_107 | bi | a8591 交易/订单多表 | 3,202 万 | 66 | BI 交易报表(buyUser/sellUser 多表 JOIN) | 大 JOIN 扫描 |
| 8 | 2990.2s | 8591 / ZHDX_t8591_107 | bi | a8591.t8_mall_stat | 3.23 亿 | 1.62 亿 | 同 #3 | 全表扫描 + 大结果集传输 |
| 9 | 2914.5s | 8591 / ZHDX_t8591_107 | bi | a8591.t8_mall_stat | 3.23 亿 | 1.61 亿 | 同 #3 | 全表扫描 + 大结果集传输 |
| 10 | 2706.3s | 8591 / ZHDX_t8591_107 | bi | a8591 订单多表 | 3,651 万 | 293 万 | BI 订单报表(IFNULL 多路 JOIN) | 大 JOIN 扫描 + 大结果集 |
Top10 关键结论
bi 用户、集中在 BI 从库(ZHDX_t591_148、ZHDX_t8591_107),全部为只读 SELECT,无锁等待型。SELECT * FROM t8_mall_stat ORDER BY created_at DESC 一天执行 4 次以上、每次约 50~80 分钟。EXPLAIN(8591-a 实测):access_type=ALL、rows_examined_per_scan=21,642,902、using_filesort=true,单次返回 1.6 亿行。t8_mall_stat 上只有 mall_id、mcd_index 两个索引,created_at 无索引 → 全表扫描 + filesort + 宽行全量传输。activity_plan_money 走 type 索引仍需扫 745 万行/次,sale 走 user_id 索引;#2 的 EXPLAIN 直接超时(查询代价过大)。对 59,026 条明细做 SQL 指纹归一化(字符串/数字/IN 列表 → ?)后聚合。
| # | 条数 | 累计耗时 | 平均 | 最大 | 用户 | 指纹(骨架) | 深度分析 |
|---|---|---|---|---|---|---|---|
| 1 | 3,932 | 20,072.8s (5.6h) | 5.11s | 14.7s | t8891 | select * from t_member_devices where (m_id=? and hash=?) limit ? | ✅(见 3.3-P1) |
| 2 | 3,642 | 6,128.9s (1.7h) | 1.68s | 14.7s | tw591 | select count(*) from sale where status=? and closed=? and community_id=? and kind IN (?) and posttime>=? | ✅(P2) |
| 3 | 2,935 | 10,319.3s (2.9h) | 3.52s | 7.2s | a8591 | SELECT c.* FROM t8_user_id_card_number_list c WHERE img_type=? AND status=? AND image!=? AND (ocr_result=? or null) ORDER BY id ASC LIMIT ? | ✅(P3) |
| 4 | 2,600 | 3,489.0s (58min) | 1.34s | 1.9s | a591 | select t1_design_img.* ... join t1_design_work ... where check_status=? and is_show=? ... | ✅(P4) |
| 5 | 2,080 | 10,371.5s (2.9h) | 4.99s | 33.4s | tw591 | select community_id, MIN(user_id) from t591.sale join t591_new.market_community_agent_bid_record b ... join im_user_bind im ... | ✅(P5) |
| # | 条数 | 累计耗时 | 平均 | 最大 | 用户 | 指纹(骨架) | 深度分析 |
|---|---|---|---|---|---|---|---|
| 1 | 3,932 | 20,072.8s (5.6h) | 5.11s | 14.7s | t8891 | 同 3.1-#1 | ✅(P1) |
| 2 | 363 | 13,938.9s (3.9h) | 38.4s | 107.3s | a8591 | select sum(searched_times) total, keyword from t8_keyword_statistics where date between ? and ? group by keyword order by total desc limit ? | ✅(P6) |
| 3 | 2,080 | 10,371.5s (2.9h) | 4.99s | 33.4s | tw591 | 同 3.1-#5 | ✅(P5) |
| 4 | 2,935 | 10,319.3s (2.9h) | 3.52s | 7.2s | a8591 | 同 3.1-#3 | ✅(P3) |
| 5 | 1,845 | 9,200.2s (2.6h) | 4.99s | 7.9s | t8891 | select f_id, COUNT(*) from t_carinfo_favorite where m_id IN (?) and type=? and exists (select * from t_carinfo_search_base_kind ...) | ✅(P7) |
backup 模式:两表中无 user=backup(mysqldump)模式入选;全部高频模式均为业务/BI 查询,且全部触发深度分析(条数>100)。
P1 · t8891.t_member_devices(3932 条 / 累计 5.6h)— 头号模式
select * from t_member_devices where m_id=? and hash=? limit 1,均 5.1s,分布在 YCJF_t8891_24/25 全部实例。t_member_devices_m_id_index(仅 m_id 单列),rows_examined_per_scan≈800,287 —— hash 条件不在索引里,单个 m_id 下几十万设备行逐行回表过滤。ALTER TABLE t8891.t_member_devices ADD INDEX idx_m_id_hash (m_id, hash);(现有 m_id 单列索引可被其完全替代,评估后删除 t_member_devices_m_id_index)。该索引可把扫描行数从 80 万降到 1,预计消除全天 5.6 小时慢查询。P2 · t591.sale 社区计数(3642 条 / 1.7h)
idx_community_id(单列),rows≈1336,再逐行过滤 status/closed/kind/posttime。sale (community_id, status, closed, kind, posttime)(或至少 (community_id, posttime));这是 CDC 链路(/* ms:tw591ms-cdc */)发出的查询,索引收益直接降低主从延迟。P3 · a8591.t8_user_id_card_number_list(2935 条 / 2.9h)
ORDER BY id ASC LIMIT 1 走 PRIMARY 全索引顺序扫描,从 id=1 开始逐行回表检查 img_type/status/ocr_result 条件,扫到第一条匹配为止(本例 explain 命中快,真实负载下匹配行越晚出现越慢,平均 3.5s)。ALTER TABLE a8591.t8_user_id_card_number_list ADD INDEX idx_type_status_id (img_type, status, id); 该查询是轮询消费型(OCR 重试队列),索引后可变成点查。P4 · t591.t1_design_work/design_img 装潢列表(2600 条 / 58min,a591 用户,ZHDX_t8591_73)
check_status 复合索引 range 扫 15,463 行、backward index scan、覆盖索引、无 filesort——计划本身健康;1.34s 均耗主要来自 JOIN t1_design_img 宽行(views/favor_count 等展示列)回表。(w_id, views, favor_count, ...)。收益中等,非最优先。P5 · t591 竞价社区代理(2080 条 / 2.9h,max 33.4s)
idx_community_id range 15,363 行 → JOIN market_community_agent_bid_record 走 idx_user_id 每行 431 行 → JOIN im_user_bind 1 行。中间层 431 行/次的 fan-out 是主要成本(15363×431 量级),且 b 表还要再按 start_time/end_time 过滤。t591_new.market_community_agent_bid_record 建 (user_id, start_time, end_time) 复合索引;给 im_user_bind (im_uid) 确认已有 uid 索引。此模式与 Top10-#1 同族,索引一并受益。P6 · a8591.t8_keyword_statistics 关键词月度汇总(363 条 / 累计 3.9h,单条均 38.4s、max 107s)
idx_date_keyword_searched_times 669,892 行(using_index 覆盖),但 GROUP BY keyword + ORDER BY sum() 触发 temporary + filesort,data_read_per_join≈669MB。(keyword, date) 索引让 GROUP BY 走索引序;② 更优:增加按日/按周预聚合表或把「热门关键词 Top5」做缓存(该查询一天 363 次、结果按天变化,缓存命中率极高)。P7 · t8891.t_carinfo_favorite EXISTS 计数(1845 条 / 2.6h)
m_id_type (m_id, type) 复合索引,IN+type 条件本身可走。EXISTS (select * from t_carinfo_search_base_kind where favorite.f_id = base_kind...) 子查询若 t_carinfo_search_base_kind 关联列无索引,外层每个 f_id 都触发一次子查询全扫。t_carinfo_search_base_kind 上关联列(f_id/id)是否有索引,无则补;外层可确认走 m_id_type。created_at 索引可消 filesort,但根本问题是 SELECT * 全量 1.6 亿行导出:改为分页/分批(WHERE created_at > 游标 LIMIT n)或落地到离线数仓,避免每次 50~80 分钟占用 BI 从库。http://192.168.8.75:8200/mcp(fastmcp Client)es_slow_logs(top=10,prod-591 / prod-8591 / prod-8891 合并)es_search(索引 mysql-slow_2026.09,按 @timestamp 过滤,翻页抽样 59,026 条)connect / describe_schema / explain / disconnect(MySQL 只读分析,涉及 prod-591/master、prod-8591/8591-a、prod-8591/8591-b、prod-8591/100、prod-8891/master).agents/scripts/slow_report_20260909.py + slow_report_20260909_fix.py;中间数据:outputs/analysis_20260909.json。