Files
monisuo/sql/patch_p0_indexes.sql

17 lines
804 B
MySQL
Raw Normal View History

2026-04-21 08:12:17 +08:00
-- ============================================
-- P0 性能优化:关键复合索引
-- 执行环境所有环境dev/prd
-- ============================================
-- 限价单撮合查询每3秒执行一次
-- 对应查询WHERE coin_code=? AND order_type=2 AND status=0 ORDER BY create_time ASC
ALTER TABLE order_trade ADD INDEX idx_coin_type_status_time (coin_code, order_type, status, create_time);
-- 资金流水查询(资产页、福利查询)
-- 对应查询WHERE user_id=? AND flow_type=? ORDER BY create_time DESC
ALTER TABLE account_flow ADD INDEX idx_user_flow_type_time (user_id, flow_type, create_time);
-- 盈亏日志按用户+类型查询
-- 对应查询WHERE user_id=? AND type=?
ALTER TABLE user_profit_log ADD INDEX idx_user_type (user_id, type);