feat:浦江优化
This commit is contained in:
1 parent
da549b19aa
commit
7ae8d3e14b
7 files changed
+77
-8
No files matched your search
@@ -0,0 +1,21 @@
|
||||
-- wallet_code_use 补二级索引(饭点卡顿波次 2026-09-14 诊断配套,PolarDB 分布式版 MySQL8 兼容模式)
|
||||
-- 背景:该表此前仅有主键,慢日志实测 UPDATE 全表扫描并锁定全部扫描行:
|
||||
-- UPDATE wallet_code_use SET del_flag = '1'
|
||||
-- WHERE del_flag = '0' AND user_id = ? AND biz_type = '5' AND biz_id = ?
|
||||
-- 扫描 14,653 行、单次耗时最长达 11 秒(波次期间),锁面放大拥堵。
|
||||
-- 索引设计说明:biz_type 为 tinytext 无法进入普通二级索引;user_id + biz_id 组合
|
||||
-- 已可把扫描范围缩到该用户名下几行,biz_type 在索引外过滤,无需进索引。
|
||||
-- idx_wcu_biz 单列索引服务 WalletCodeUseServiceImpl.getInfoByShortCode 按 biz_id 查询。
|
||||
-- 执行前请确认同名索引不存在:SHOW INDEX FROM pjcloudx_wallet.wallet_code_use;
|
||||
-- 表仅约 1.5 万行,Online DDL 秒级完成,无锁风险;本文件只包含索引 DDL。
|
||||
|
||||
ALTER TABLE pjcloudx_wallet.wallet_code_use
|
||||
ADD INDEX idx_wcu_user_biz (user_id, biz_id),
|
||||
ADD INDEX idx_wcu_biz (biz_id);
|
||||
|
||||
-- 说明:
|
||||
-- 1) 全量建库脚本 db/800pjcloudx_wallet.sql 已同步补上这两个索引,新建环境无需再执行本文件。
|
||||
-- 2) 两条索引合并在一条 ALTER 中执行,只做一次表重建;如需拆开单独执行(参考
|
||||
-- hard_order verification_time 加列时的生产执行惯例),可改为两条独立的 CREATE INDEX 语句:
|
||||
-- CREATE INDEX idx_wcu_user_biz ON pjcloudx_wallet.wallet_code_use (user_id, biz_id);
|
||||
-- CREATE INDEX idx_wcu_biz ON pjcloudx_wallet.wallet_code_use (biz_id);
|
||||
@@ -540,7 +540,9 @@ CREATE TABLE wallet_code_use
|
||||
update_time datetime DEFAULT NULL COMMENT '修改时间',
|
||||
del_flag char(1) COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '删除标记',
|
||||
tenant_id bigint DEFAULT NULL COMMENT '租户ID',
|
||||
PRIMARY KEY (id)
|
||||
PRIMARY KEY (id),
|
||||
INDEX idx_wcu_user_biz (user_id, biz_id),
|
||||
INDEX idx_wcu_biz (biz_id)
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4 COMMENT ='二维码使用表';
|
||||
|
||||
|
||||
Reference in new issue
Block a user