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

MySQL 慢查询日报(线上 prod8591)2026-11-01

统计概览

项目值
统计范围2026-11-01 00:00:00 ~ 23:59:59(Asia/Shanghai)
环境prod-8591
慢日志条数(ES mysql-slow_*)76,313 条(指纹聚合取样 20,316 条,覆盖率 27%,超过 2 万条上限截断)
Top10 单条最慢6,232.39 s(user=bi,ZHDX_t8591_107)
非备份模式最大累计3.71h(3714 次 × 3.60 s)
备份模式(user 含 backup/databasus_backup)492 条、累计 10.98h(单独标注,不触发深析)
监控巡检类(jmysql/proxysql_monitor 或 information_schema)742 条、累计 23.3min(多为 # Schema: 空导致采集端 _grokparsefailure、无库名;单独标注,不触发深析)
深析模式 explain 成功率8/8(100%)
数据来源ES mysql-slow_*(@timestamp)+ MCP 只读 MySQL(describe_schema/explain)
生成时间2026-11-02 09:51(Asia/Shanghai)

Top10 明细(按单条耗时)

#耗时(s)库.表行数 sent/examineduser / server慢因分类
16,232.39a8591.t8_mall_stat176,584,115 / 353,168,230bi / ZHDX_t8591_107EXPLAIN 全表扫描/未用索引、排序未走索引(filesort)
25,872.41a8591.t8_ware_item_desc23,653,497 / 23,653,497databasus_backup / ZHDX_t8591_52EXPLAIN 全表扫描/未用索引
34,370.35a8591.t8_mall_stat176,761,208 / 353,522,416bi / ZHDX_t8591_107EXPLAIN 全表扫描/未用索引、排序未走索引(filesort)
44,359.78a8591.t8_ware_order3,413,635 / 38,816,562bi / ZHDX_t8591_107扫描行数远大于返回行数(38,816,562/3,413,635)、索引范围扫描量过大(t8_ware_order: key=order_createtime, rows=6,683,992)
53,467.12a8591.ware_item_history112 / 32,017,831bi / ZHDX_t8591_107扫描行数远大于返回行数(32,017,831/112)、EXPLAIN 全表扫描/未用索引
63,462.71a8591.ware_item_history1,283,204 / 11,741,249bi / ZHDX_t8591_107EXPLAIN 全表扫描/未用索引
73,431.18a8591.t8_mall_stat176,824,362 / 353,648,724bi / ZHDX_t8591_107EXPLAIN 全表扫描/未用索引、排序未走索引(filesort)
83,376.63t8_game.t8_embeddings_cache956,905 / 956,905databasus_backup / ZHDX_t8591_91其他(需结合 SQL 与执行计划人工判断)
93,352.71a8591.ware_item_history114 / 32,017,833bi / ZHDX_t8591_107扫描行数远大于返回行数(32,017,833/114)、EXPLAIN 全表扫描/未用索引
103,236.77a8591.t8_mall_stat176,701,313 / 353,402,626bi / ZHDX_t8591_107EXPLAIN 全表扫描/未用索引、排序未走索引(filesort)

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

按条数 Top5

#模式(指纹摘要)条数平均(s)累计serveruser
1SELECT c.* FROM t8_user_id_card_number_list AS c WHERE c.img_type = ? AND c.status = ? AND c.image != ? AND (c.ocr_result = ? or c.ocr_result is null) ORDER BY c.id ASC,c.id LIMIT ?;3,7143.603.71hZHDX_t8591_143,ZHDX_t8591_16,ZHDX_t8591_a8591
2SELECT id FROM ware_item WHERE id > ? AND status > ? AND (actionTime BETWEEN ? AND ? ) ORDER BY id ASC LIMIT ?;9561.7227.3minZHDX_t8591_61a8591
3
SELECT g.id AS game_id, g.name, pg.id AS platform_game_id, pg.platform_app_id FROM t8_platform_games pg INNER JOIN t8_games g ON g.id = pg.game_id WHERE pg.plat …(点击展开完整 SQL)
SELECT g.id AS game_id, g.name, pg.id AS platform_game_id, pg.platform_app_id FROM t8_platform_games pg INNER JOIN t8_games g ON g.id = pg.game_id WHERE pg.platform_id = ? AND pg.enable = ? AND pg.id > ? AND pg.platform_app_id IS NOT NULL AND pg.platform_app_id <> ? AND g.type = ? AND g.enable = ? AND NOT EXISTS ( SELECT ? FROM t8_platform_game_media pgm WHERE pgm.platform_game_id = pg.id AND pgm.scene_type = ? LIMIT ? ) ORDER BY pg.id ASC LIMIT ?;
8685.631.36hZHDX_t8591_136a8591
4
select i.*, COALESCE(v.views_30d, ?) AS views_30d, COALESCE(vip.vip_level, ?) AS vip_level, COALESCE(uc.collections_30d, ?) AS collections_30d from t1_design_im …(点击展开完整 SQL)
select i.*, COALESCE(v.views_30d, ?) AS views_30d, COALESCE(vip.vip_level, ?) AS vip_level, COALESCE(uc.collections_30d, ?) AS collections_30d from t1_design_img as i left join t1_design_work as w on w.id = i.w_id left join (select c.company_id, c.work_id, MAX(c.level_order) AS vip_level from t1_vip_benefit_calendar as c where c.date = ? and c.benefit_type = ? and c.region_id > ? group by c.company_id, c.work_id) as vip on vip.company_id = w.design_id and vip.work_id = i.w_id left join (select source_id, COALESCE(SUM(view_count), ?) AS views_30d from t1_visits where source_type = ? and date >= ? group by source_id) as v on v.source_id = i.id left join (select work_id, COUNT(*) AS collections_30d from t1_user_collect where type = ? and created_at >= ? group by work_id) as uc on uc.work_id = i.id where i.id > ? order by i.id asc limit ?;
7853.3643.9minZHDX_t8591_73a591
5
SELECT t.table_schema, t.table_name, column_name, auto_increment, pow(?, case data_type when ? then ? when ? then ? when ? then ? when ? then ? when ? then ? en …(点击展开完整 SQL)
SELECT t.table_schema, t.table_name, column_name, auto_increment, pow(?, case data_type when ? then ? when ? then ? when ? then ? when ? then ? when ? then ? end+(column_type like ?))-? as max_int FROM information_schema.columns c STRAIGHT_JOIN information_schema.tables t ON BINARY t.table_schema = c.table_schema AND BINARY t.table_name = c.table_name WHERE c.extra = ? AND t.auto_increment IS NOT NULL;
🔍监控
6471.7218.6minZHDX_t8591_143,ZHDX_t8591_16,ZHDX_t8591_jmysql

按累计耗时 Top5

#模式条数平均(s)累计serveruser
1SELECT c.* FROM t8_user_id_card_number_list AS c WHERE c.img_type = ? AND c.status = ? AND c.image != ? AND (c.ocr_result = ? or c.ocr_result is null) ORDER BY c.id ASC,c.id LIMIT ?;3,7143.603.71hZHDX_t8591_143,ZHDX_t8591_16,ZHDX_t8591_a8591
2SELECT * FROM t8_mall_stat ORDER BY created_at DESC;24734.582.63hZHDX_t8591_107bi
3SELECT /*!? SQL_NO_CACHE */ * FROM a8591.t8_ware_item_desc; 🗄备份15872.411.63hZHDX_t8591_52databasus_backup
4select wallet, sum(if(type = ?, amount, ?)) - sum(if(type = ?, amount, ?)) as balance from a8591.t8_money_trade_log where account = ? and created_at <= ? group by wallet;10648.821.44hZHDX_t8591_61a8591
5
SELECT g.id AS game_id, g.name, pg.id AS platform_game_id, pg.platform_app_id FROM t8_platform_games pg INNER JOIN t8_games g ON g.id = pg.game_id WHERE pg.plat …(点击展开完整 SQL)
SELECT g.id AS game_id, g.name, pg.id AS platform_game_id, pg.platform_app_id FROM t8_platform_games pg INNER JOIN t8_games g ON g.id = pg.game_id WHERE pg.platform_id = ? AND pg.enable = ? AND pg.id > ? AND pg.platform_app_id IS NOT NULL AND pg.platform_app_id <> ? AND g.type = ? AND g.enable = ? AND NOT EXISTS ( SELECT ? FROM t8_platform_game_media pgm WHERE pgm.platform_game_id = pg.id AND pgm.scene_type = ? LIMIT ? ) ORDER BY pg.id ASC LIMIT ?;
8685.631.36hZHDX_t8591_136a8591
备份模式全天 492 条 / 10.98h,未触发深度分析(如条数环比异常翻倍再人工介入)。

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

1. SELECT c.* FROM t8_user_id_card_number_list AS c WHERE c.img_type = ? AND c.status = ? AND c.image != ? AND (c.ocr_result = ? or c.ocr_result is null) ORDER BY —— 3,714 次 × 3.60s = 3.71h

SELECT c.* FROM t8_user_id_card_number_list AS c WHERE c.img_type = 2 AND c.status = 2 AND c.image != '' AND (c.ocr_result = '' or c.ocr_result is null) ORDER BY c.id ASC,`c`.`id` LIMIT 1;
SELECT c.* FROM `a8591`.`t8_user_id_card_number_list` AS c WHERE c.img_type = 2 AND c.status = 2 AND c.image != '' AND (c.ocr_result = '' or c.ocr_result is null) ORDER BY c.id ASC,`c`.`id` LIMIT 1;
#表访问类型使用索引候选索引预扫行数过滤后
1c⚠️ 全索引扫描PRIMARY—15.0%
ALTER TABLE `a8591`.`t8_user_id_card_number_list` ADD INDEX `idx_img_type_status_ocr_result` (`img_type`, `status`, `ocr_result`);

2. SELECT * FROM t8_mall_stat ORDER BY created_at DESC; —— 2 次 × 4734.58s = 2.63h

SELECT *
FROM t8_mall_stat
ORDER BY created_at DESC;
SELECT *
FROM `a8591`.`t8_mall_stat`
ORDER BY created_at DESC;
#表访问类型使用索引候选索引预扫行数过滤后
1t8_mall_stat❌ 全表扫描——21,641,358100.0%
ALTER TABLE `a8591`.`t8_mall_stat` ADD INDEX `idx_created_at` (`created_at`);

3. select wallet, sum(if(type = ?, amount, ?)) - sum(if(type = ?, amount, ?)) as balance from a8591.t8_money_trade_log where account = ? and created_at <= ? group —— 106 次 × 48.82s = 1.44h

select wallet, sum(if(type = 2, amount, 0)) - sum(if(type = 1, amount, 0)) as balance from `a8591`.`t8_money_trade_log` where `account` = 'A0100' and `created_at` <= '2026-11-01 03:59:50' group by `wallet`;
select wallet, sum(if(type = 2, amount, 0)) - sum(if(type = 1, amount, 0)) as balance from `a8591`.`t8_money_trade_log` where `account` = 'A0100' and `created_at` <= '2026-11-01 03:59:50' group by `wallet`;
#表访问类型使用索引候选索引预扫行数过滤后
1t8_money_trade_logrefidx_awidx_created_at,idx_aw29,809,16050.0%
ALTER TABLE `a8591`.`t8_money_trade_log` ADD INDEX `idx_account_created_at` (`account`, `created_at`);

4. SELECT g.id AS game_id, g.name, pg.id AS platform_game_id, pg.platform_app_id FROM t8_platform_games pg INNER JOIN t8_games g ON g.id = pg.game_id WHERE pg.plat —— 868 次 × 5.63s = 1.36h

SELECT
                    g.id AS game_id,
                    g.name,
                    pg.id AS platform_game_id,
                    pg.platform_app_id
                FROM t8_platform_games pg
                INNER JOIN t8_games g
                    ON g.id = pg.game_id
                WHERE pg.platform_id = 1
                  AND pg.enable = 1
                  AND pg.id > 0
                  AND pg.platform_app_id IS NOT NULL
                  AND pg.platform_app_id <> ''
                  AND g.type = 'game'
                  AND g.enable = 1
                  AND NOT EXISTS (
                      SELECT 1
                      FROM t8_platform_game_media pgm
                      WHERE pgm.platform_game_id = pg.id
                        AND pgm.scene_type = 7
                      LIMIT 1
                  )
                ORDER BY pg.id ASC
                LIMIT 450;
SELECT
                    g.id AS game_id,
                    g.name,
                    pg.id AS platform_game_id,
                    pg.platform_app_id
                FROM `t8_game`.`t8_platform_games` pg
                INNER JOIN `t8_game`.`t8_games` g
                    ON g.id = pg.game_id
                WHERE pg.platform_id = 1
                  AND pg.enable = 1
                  AND pg.id > 0
                  AND pg.platform_app_id IS NOT NULL
                  AND pg.platform_app_id <> ''
                  AND g.type = 'game'
                  AND g.enable = 1
                  AND NOT EXISTS (
                      SELECT 1
                      FROM `t8_game`.`t8_platform_game_media` pgm
                      WHERE pgm.platform_game_id = pg.id
                        AND pgm.scene_type = 7
                      LIMIT 1
                  )
                ORDER BY pg.id ASC
                LIMIT 450;
#表访问类型使用索引候选索引预扫行数过滤后
1greftypePRIMARY,type238,45010.0%
2pgrefidx_enable_gamePRIMARY,idx_bid,idx_platform,idx_enable_game125.0%
ALTER TABLE `t8_game`.`t8_platform_games` ADD INDEX `idx_game_id_platform_i_enable_platform_a_id` (`game_id`, `platform_id`, `enable`, `platform_app_id`, `id`);
ALTER TABLE `t8_game`.`t8_games` ADD INDEX `idx_type_enable` (`type`, `enable`);
ALTER TABLE `t8_game`.`t8_platform_game_media` ADD INDEX `idx_platform_g_scene_type` (`platform_game_id`, `scene_type`);

5. SELECT a.user_id AS buyerId, IFNULL(c.sellUser,IFNULL(d.sellUser,NULL)) AS sellerId, a.order_number AS orderNo, IFNULL(c.id,IFNULL(d.id,NULL)) AS txNo, a.order_ —— 1 次 × 4359.78s = 1.21h

SELECT
	a.user_id AS buyerId,
	IFNULL(c.sellUser,IFNULL(d.sellUser,NULL)) AS sellerId,
	a.order_number AS orderNo,
	IFNULL(c.id,IFNULL(d.id,NULL)) AS txNo,
	a.order_status AS orderStatus,
	IFNULL(c.status,IFNULL(d.status,NULL)) AS txStatus,
  IFNULL(e.type,IFNULL(f.type,NULL)) AS gameType,
  CONVERT(CAST(IFNULL(e.name,IFNULL(f.name,NULL)) AS BINARY) USING utf8) AS gameName,
  CONVERT(CAST(IFNULL(g.type_name,IFNULL(h.type_name,NULL)) AS BINARY) USING utf8) AS goodsType,
  CONVERT(CAST(IFNULL(c.title,IFNULL(d.title,NULL)) AS BINARY) USING utf8) AS goodsTitle,
	a.pay_by AS payMethod,
	a.user_agent AS orderClient,
	IFNULL(c.price,IFNULL(d.price,NULL)) AS price,
	a.voucher_money AS couponAmount,
	i.active_id AS activityName,
	i.coupon_id AS couponId,
	IF(IFNULL(j.set_type,IFNULL(k.set_type,NULL)) = 'specifyBuyer','yes','no') AS IF_special,
	IF(a.order_createtime NOT LIKE '0000-00-00 00:00:00', a.order_createtime, NULL) AS createTime,
	IF(a.order_paytime NOT LIKE '0000-00-00 00:00:00', a.order_paytime, NULL) AS payTime,
	FROM_UNIXTIME( IFNULL(IF(c.actionTime=0,NULL,c.actionTime),IFNULL(IF(d.actionTime=0,NULL,d.actionTime),NULL)), '%Y-%m-%d %H:%i:%s' ) AS actionTime,
	IF(a.order_canceltime NOT LIKE '0000-00-00 00:00:00', a.order_canceltime, NULL) AS cancelTime
FROM
	t8_ware_order a
	LEFT JOIN t8_ware_order_item b ON a.id = b.order_id
	LEFT JOIN ware_item c ON b.ware_id = c.id
	LEFT JOIN ware_item_history d ON b.ware_id = d.id
	LEFT JOIN gameList e ON c.gameName = e.id
	LEFT JOIN gameList f ON d.gameName = f.id
	LEFT JOIN t8_ware_type g ON c.wareType = g.id
	LEFT JOIN t8_ware_type h ON d.wareType = h.id
	LEFT JOIN t8_user_voucher i ON a.voucher_id = i.id
	LEFT JOIN ( SELECT * FROM ware_set WHERE set_type = 'specifyBuyer' ) j ON c.id = j.ware_id
	LEFT JOIN ( SELECT * FROM ware_set WHERE set_type = 'specifyBuyer' ) k ON d.id = k.ware_id
WHERE 
	a.order_createtime >= '2026-01-01' AND a.order_createtime < '2027-01-01'
ORDER BY 
	a.order_createtime DESC;
SELECT * FROM `a8591`.`t8_ware_order` WHERE order_createtime >= '2026-01-01' LIMIT 10
#表访问类型使用索引候选索引预扫行数过滤后
1t8_ware_orderrangeorder_createtimeorder_createtime6,685,148100.0%

6. SELECT a.buyUser AS buyerId, a.sellUser AS sellerId, c.order_number AS orderNo, a.id AS txNo, c.order_status AS orderStatus, a.status AS txStatus, d.type AS gam —— 1 次 × 3467.12s = 57.8min

SELECT
	a.buyUser AS buyerId,
	a.sellUser AS sellerId,
	c.order_number AS orderNo,
	a.id AS txNo,
	c.order_status AS orderStatus,
	a.status AS txStatus,
	d.type AS gameType,
	CONVERT ( CAST( d.NAME AS BINARY ) USING utf8 ) AS gameName,
	CONVERT ( CAST( e.type_name AS BINARY ) USING utf8 ) AS goodsType,
	CONVERT ( CAST( a.title AS BINARY ) USING utf8 ) AS goodsTitle,
	c.pay_by AS payMethod,
	c.user_agent AS orderClient,
	a.price AS price,
	f.money AS couponAmount,
	f.active_id AS activityName,
	f.coupon_id AS couponId,
	IF ( g.set_type = 'specifyBuyer', 'yes', 'no' ) AS IF_special,
	IF ( c.order_createtime != '0000-00-00 00:00:00', c.order_createtime, NULL ) AS createTime,
	IF ( c.order_paytime != '0000-00-00 00:00:00', c.order_paytime, NULL ) AS payTime,
	FROM_UNIXTIME( IF ( a.actionTime = 0, NULL, a.actionTime ), '%Y-%m-%d %H:%i:%s' ) AS actionTime,
	IF ( c.order_canceltime != '0000-00-00 00:00:00', c.order_canceltime, NULL ) AS cancelTime
FROM
	ware_item_history a
	LEFT JOIN t8_ware_order_item b ON a.id = b.ware_id 
	LEFT JOIN t8_ware_order c ON b.order_id = c.id
	LEFT JOIN gameList d ON a.gameName = d.id
	LEFT JOIN t8_ware_type e ON a.wareType = e.id
	LEFT JOIN t8_user_voucher f ON b.ware_id = f.id
	LEFT JOIN ( SELECT * FROM ware_set WHERE set_type = 'specifyBuyer' ) g ON a.id = g.ware_id
WHERE
	a.postTime >= 1546272000 
	AND c.order_number IS NULL;
SELECT
	a.buyUser AS buyerId,
	a.sellUser AS sellerId,
	c.order_number AS orderNo,
	a.id AS txNo,
	c.order_status AS orderStatus,
	a.status AS txStatus,
	d.type AS gameType,
	CONVERT ( CAST( d.NAME AS BINARY ) USING utf8 ) AS gameName,
	CONVERT ( CAST( e.type_name AS BINARY ) USING utf8 ) AS goodsType,
	CONVERT ( CAST( a.title AS BINARY ) USING utf8 ) AS goodsTitle,
	c.pay_by AS payMethod,
	c.user_agent AS orderClient,
	a.price AS price,
	f.money AS couponAmount,
	f.active_id AS activityName,
	f.coupon_id AS couponId,
	IF ( g.set_type = 'specifyBuyer', 'yes', 'no' ) AS IF_special,
	IF ( c.order_createtime != '0000-00-00 00:00:00', c.order_createtime, NULL ) AS createTime,
	IF ( c.order_paytime != '0000-00-00 00:00:00', c.order_paytime, NULL ) AS payTime,
	FROM_UNIXTIME( IF ( a.actionTime = 0, NULL, a.actionTime ), '%Y-%m-%d %H:%i:%s' ) AS actionTime,
	IF ( c.order_canceltime != '0000-00-00 00:00:00', c.order_canceltime, NULL ) AS cancelTime
FROM
	`a8591`.`ware_item_history` a
	LEFT JOIN `a8591`.`t8_ware_order_item` b ON a.id = b.ware_id 
	LEFT JOIN `a8591`.`t8_ware_order` c ON b.order_id = c.id
	LEFT JOIN `a8591`.`gameList` d ON a.gameName = d.id
	LEFT JOIN `a8591`.`t8_ware_type` e ON a.wareType = e.id
	LEFT JOIN `a8591`.`t8_user_voucher` f ON b.ware_id = f.id
	LEFT JOIN ( SELECT * FROM `a8591`.`ware_set` WHERE set_type = 'specifyBuyer' ) g ON a.id = g.ware_id
WHERE
	a.postTime >= 1546272000 
	AND c.order_number IS NULL;
#表访问类型使用索引候选索引预扫行数过滤后
1a❌ 全表扫描—postTime15,803,708100.0%
2brefware_idware_id1100.0%
3ceq_refPRIMARYPRIMARY110.0%
4deq_refPRIMARYPRIMARY1100.0%
5eeq_refPRIMARYPRIMARY1100.0%
6feq_refPRIMARYPRIMARY1100.0%
7ware_setrefware_idware_id,set_type6100.0%
ALTER TABLE `a8591`.`ware_item_history` ADD INDEX `idx_gameName_wareType_set_type_postTime` (`gameName`, `wareType`, `set_type`, `postTime`);
ALTER TABLE `a8591`.`t8_ware_order_item` ADD INDEX `idx_ware_id_order_id` (`ware_id`, `order_id`);

7. SELECT a.buyUser AS buyerId, a.sellUser AS sellerId, c.order_number AS orderNo, a.id AS txNo, c.order_status AS orderStatus, a.status AS txStatus, d.type AS gam —— 1 次 × 3462.71s = 57.7min

SELECT
	a.buyUser AS buyerId,
	a.sellUser AS sellerId,
	c.order_number AS orderNo,
	a.id AS txNo,
	c.order_status AS orderStatus,
	a.status AS txStatus,
	d.type AS gameType,
	CONVERT ( CAST( d.NAME AS BINARY ) USING utf8 ) AS gameName,
	CONVERT ( CAST( e.type_name AS BINARY ) USING utf8 ) AS goodsType,
	CONVERT ( CAST( a.title AS BINARY ) USING utf8 ) AS goodsTitle,
	c.pay_by AS payMethod,
	c.user_agent AS orderClient,
	a.price AS price,
	f.money AS couponAmount,
	f.active_id AS activityName,
	f.coupon_id AS couponId,
	IF ( g.set_type = 'specifyBuyer', 'yes', 'no' ) AS IF_special,
	IF ( c.order_createtime != '0000-00-00 00:00:00', c.order_createtime, NULL ) AS createTime,
	IF ( c.order_paytime != '0000-00-00 00:00:00', c.order_paytime, NULL ) AS payTime,
	FROM_UNIXTIME( IF ( a.actionTime = 0, NULL, a.actionTime ), '%Y-%m-%d %H:%i:%s' ) AS actionTime,
	IF ( c.order_canceltime != '0000-00-00 00:00:00', c.order_canceltime, NULL ) AS cancelTime
FROM
	ware_item a
	LEFT JOIN t8_ware_order_item b ON a.id = b.ware_id 
	LEFT JOIN t8_ware_order c ON b.order_id = c.id
	LEFT JOIN gameList d ON a.gameName = d.id
	LEFT JOIN t8_ware_type e ON a.wareType = e.id
	LEFT JOIN t8_user_voucher f ON b.ware_id = f.id
	LEFT JOIN ( SELECT * FROM ware_set WHERE set_type = 'specifyBuyer' ) g ON a.id = g.ware_id
WHERE
	a.postTime >= 1546272000 
	AND c.order_number IS NULL
ORDER BY 
	actionTime DESC;
SELECT
	a.buyUser AS buyerId,
	a.sellUser AS sellerId,
	c.order_number AS orderNo,
	a.id AS txNo,
	c.order_status AS orderStatus,
	a.status AS txStatus,
	d.type AS gameType,
	CONVERT ( CAST( d.NAME AS BINARY ) USING utf8 ) AS gameName,
	CONVERT ( CAST( e.type_name AS BINARY ) USING utf8 ) AS goodsType,
	CONVERT ( CAST( a.title AS BINARY ) USING utf8 ) AS goodsTitle,
	c.pay_by AS payMethod,
	c.user_agent AS orderClient,
	a.price AS price,
	f.money AS couponAmount,
	f.active_id AS activityName,
	f.coupon_id AS couponId,
	IF ( g.set_type = 'specifyBuyer', 'yes', 'no' ) AS IF_special,
	IF ( c.order_createtime != '0000-00-00 00:00:00', c.order_createtime, NULL ) AS createTime,
	IF ( c.order_paytime != '0000-00-00 00:00:00', c.order_paytime, NULL ) AS payTime,
	FROM_UNIXTIME( IF ( a.actionTime = 0, NULL, a.actionTime ), '%Y-%m-%d %H:%i:%s' ) AS actionTime,
	IF ( c.order_canceltime != '0000-00-00 00:00:00', c.order_canceltime, NULL ) AS cancelTime
FROM
	`a8591`.`ware_item` a
	LEFT JOIN `a8591`.`t8_ware_order_item` b ON a.id = b.ware_id 
	LEFT JOIN `a8591`.`t8_ware_order` c ON b.order_id = c.id
	LEFT JOIN `a8591`.`gameList` d ON a.gameName = d.id
	LEFT JOIN `a8591`.`t8_ware_type` e ON a.wareType = e.id
	LEFT JOIN `a8591`.`t8_user_voucher` f ON b.ware_id = f.id
	LEFT JOIN ( SELECT * FROM `a8591`.`ware_set` WHERE set_type = 'specifyBuyer' ) g ON a.id = g.ware_id
WHERE
	a.postTime >= 1546272000 
	AND c.order_number IS NULL
ORDER BY 
	actionTime DESC;
#表访问类型使用索引候选索引预扫行数过滤后
1a❌ 全表扫描—postTime919,58350.0%
2brefware_idware_id1100.0%
3ceq_refPRIMARYPRIMARY110.0%
4deq_refPRIMARYPRIMARY1100.0%
5eeq_refPRIMARYPRIMARY1100.0%
6feq_refPRIMARYPRIMARY1100.0%
7ware_setrefware_idware_id,set_type6100.0%
ALTER TABLE `a8591`.`ware_item` ADD INDEX `idx_gameName_wareType_set_type_postTime_actionTime` (`gameName`, `wareType`, `set_type`, `postTime`, `actionTime`);
ALTER TABLE `a8591`.`t8_ware_order_item` ADD INDEX `idx_ware_id_order_id` (`ware_id`, `order_id`);

8. SELECT order_id, ware_id FROM t8_ware_order_item; —— 1 次 × 3029.66s = 50.5min

SELECT 
	order_id,
    ware_id
FROM 
	t8_ware_order_item;
SELECT 
	order_id,
    ware_id
FROM 
	`a8591`.`t8_ware_order_item`;
#表访问类型使用索引候选索引预扫行数过滤后
1t8_ware_order_item⚠️ 全索引扫描user_id—22,988,934100.0%

逐条优化建议汇总

P 行 = 深析模式(指纹聚合,按全天累计耗时降序 P1 最大,是优化主战场);T 行 = 单条耗时 Top3 的一次性慢 SQL(多为 bi/导出查询,治理手段通常是限流/降频/移到从库,而非建索引)。
编号对象建议
P1a8591.t8_user_id_card_number_list(3,714×3.6s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; 扩复合索引: 把其余 WHERE 等值列追加到现有索引尾部, 避免 10 万+ 行回表; DDL: ALTER TABLE a8591.t8_user_id_card_number_list ADD INDEX idx_img_type_status_ocr_result (img_type, status, ocr_result);
P2a8591.t8_mall_stat(2×4734.6s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE a8591.t8_mall_stat ADD INDEX idx_created_at (created_at);; 把 ORDER BY 列纳入复合索引, 或减小排序前扫描范围; 改分页/按需列, 避免 SELECT * 整表捞取; 大导出走离线通道
P3a8591.t8_money_trade_log(106×48.8s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE a8591.t8_money_trade_log ADD INDEX idx_account_created_at (account, created_at);
P4t8_game.t8_platform_games(868×5.6s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE t8_game.t8_platform_games ADD INDEX idx_game_id_platform_i_enable_platform_a_id (game_id, platform_id, enable, platform_app_id, id); ALTER TABLE t8_game.t8_games ADD INDEX idx_type_enable (type, enable); ALTER TABLE t8_game.t8_platform_game_media ADD INDEX idx_platform_g_scene_type (platform_game_id, scene_type);; 缩小聚合/去重范围(补时间等过滤条件), 或预聚合到中间表/定时任务; 把 ORDER BY 列纳入复合索引, 或减小排序前扫描范围
P5a8591.t8_ware_order(1×4359.8s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中
P6a8591.ware_item_history(1×3467.1s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE a8591.ware_item_history ADD INDEX idx_gameName_wareType_set_type_postTime (gameName, wareType, set_type, postTime); ALTER TABLE a8591.t8_ware_order_item ADD INDEX idx_ware_id_order_id (ware_id, order_id);
P7a8591.ware_item(1×3462.7s)补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE a8591.ware_item ADD INDEX idx_gameName_wareType_set_type_postTime_actionTime (gameName, wareType, set_type, postTime, actionTime); ALTER TABLE a8591.t8_ware_order_item ADD INDEX idx_ware_id_order_id (ware_id, order_id);; 把 ORDER BY 列纳入复合索引, 或减小排序前扫描范围
P8a8591.t8_ware_order_item(1×3029.7s)扩复合索引: 把其余 WHERE 等值列追加到现有索引尾部, 避免 10 万+ 行回表
T1Top1(同 P2 对象) 单条最慢 1.73h,user=bi a8591.t8_mall_stat补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE a8591.t8_mall_stat ADD INDEX idx_created_at (created_at);; 把 ORDER BY 列纳入复合索引, 或减小排序前扫描范围; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库
T2Top2 单条最慢 1.63h,user=databasus_backup a8591.t8_ware_item_desc补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库
T3Top3(同 P2 对象) 单条最慢 1.21h,user=bi a8591.t8_mall_stat补索引(按 WHERE 等值列在前、范围列收尾建复合索引); 用 EXPLAIN 验证 key 命中; DDL: ALTER TABLE a8591.t8_mall_stat ADD INDEX idx_created_at (created_at);; 把 ORDER BY 列纳入复合索引, 或减小排序前扫描范围; bi/导出类: 限流降频、移从库/离线跑, 避免高峰占用主库

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