dy-dashboard/vault/知识库/工作指南/训练记录/2026-08-17-库存数据看板性能优化.md
2026-10-28 11:14:17 +08:00

10 lines
956 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

### 1. 库存数据看板强刷新性能优化
**旭东 → OpenClaw:**
> [Mon 2026-08-17 15:33 GMT+8] 发现一个异常,采销协同下的库存数据看板强刷新反应太慢了,需要等待好久才刷新成功
**OpenClaw 响应:**
已定位并修复。问题根因是库存数据看板接口中「呆滞治理」板块的首次入库日期查询(`SELECT product_code, MIN(data_date) FROM inventory_detail GROUP BY product_code`)因带了内料过滤 WHERE 条件,无法走 `idx_product_date` 覆盖索引,导致全表扫描 180 万行,耗时约 32 秒,整接口强刷新需 34.7 秒。
修复方式:去掉查询中的内料过滤 WHERE(内料在后续库存聚合/呆滞判定环节已过滤,不影响结果),使其走覆盖索引 `Using index for group-by`,该查询耗时从 31.7s 降至 0.1s,接口强刷新总耗时从 34.7s 降至 2.4s。测试服务已重启(HTTP 200)验证通过;Git 提交 71c9af3