17 lines
804 B
MySQL
17 lines
804 B
MySQL
|
|
-- ============================================
|
|||
|
|
-- 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);
|