7 Commits

Author SHA1 Message Date
liufumingren
a59793daf2 perf(order): 订单分表补列表排序索引,修复配送列表 2 秒慢查询
原因:生产 wms_order_delivery_1000028_dispatch(59.4 万行 / data 1.13GB)没有任何
索引覆盖列表接口的固定形态

  WHERE warehouse_id = ? [AND dispatch_lane = ?] ORDER BY updated_at DESC, id DESC LIMIT 20

导致主查询全表扫 + filesort(实测 1.9s);与之并行执行的同条件 COUNT(*) 因
dispatch_lane 不在索引中需逐行回表(实测 1.5s),单请求合计约 2 秒。

新增 order_delivery_table_schema.buildListSortIndexes():

- current / history / outsourced:(warehouse_id, updated_at, id) 与 (warehouse_id, delivery_time, id)
  (updated_at 为前端实际排序字段,delivery_time 为 deliveryOrder 模块默认排序字段)
- dispatch:把恒定条件列 dispatch_lane 放进前缀
  (warehouse_id, dispatch_lane, updated_at, id) 与 (warehouse_id, dispatch_lane, delivery_time, id);
  缺少该列时 COUNT(*) 仍会退回回表(实测 1.2s),且 dispatch 分支会剔除从 current
  继承来的同名后缀索引,避免同一张表维护两份功能重叠的索引
- 索引统一追加在索引数组末尾,保持既有索引下标顺序不变

验证(开发库,同一张 59.4 万行同规模表 + 应用日志中的真实 SQL):

- 主查询 1511ms(Using filesort)→ 1.0ms(Backward index scan)
- COUNT(*)  1217ms(Using where 回表)→ 197ms(Using index)

生产建议低峰期先手工建同名索引,避免部署后首个请求在建索引期间阻塞。
2026-09-15 16:03:29 +08:00
liufumingren
c5150bc35b feat: 配送表新增 dispath_time 迁移时间字段
- 新增迁移 20260907120000:为全部配送分表 wms_order_delivery_{wh}_dispatch 幂等新增 dispath_time(datetime, nullable),不触基表/当前分表/history/outsourced

- 配送表模型 schema dispatch 分支同步新增 dispath_time,drift 同步保持一致

- 订单迁移链路 buildDispatchRow 写入 dispath_time=new Date() 记录进入配送表时间
2026-09-07 16:43:35 +08:00
liufumingren
7b0004a7e3 perf(order): current 分表 wave_id 前导索引与模型预期定义同步 2026-08-30 07:28:21 +08:00
liufumingren
37104079e5 feat(order): 订单/明细 id 防回退——序列表唯一发号 + 分表免重建 + 水位自愈 + 迁移任务执行历史 2026-08-15 20:12:23 +08:00
liufumingren
9b2cc5fc73 fix(receiving): 修复获取收货单时重复定义属性的问题 2026-05-06 01:32:55 +08:00
liufumingren
0ffe290a21 chore: commit all current workspace changes 2026-04-27 16:09:26 +08:00
liufumingren
622869787a feat: sync workspace changes 2026-04-17 19:21:57 +08:00