liufumingren
18f258014f
perf(backend): 扫码记录列表补覆盖索引,count(*) 不再逐行回表
/api/web/records 是 findAndCountAll,列表本身走 idx_scan_time 只要 0.5ms,
慢的是后面那条 count(id):MySQL 只能选 (subject_id, barcode),索引里没有
scanner_id,于是按主键逐行回表判断 —— 线上 16.5 万条时 Rows_examined ≈ 33 万,
慢查询日志里 3.2s~9.9s(冷缓存时走磁盘)。
补 (subject_id, scanner_id, scan_time) 后 count 变成纯索引扫描(Using index),
实测 0.45s(热)/9.9s(冷) → 0.09s。
- 新增迁移 20261116200000-add-scan-record-list-index.js(幂等,已在生产执行)
- sql/schema.sql 基线同步该索引
- README 补索引用途与实测数字
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-11-17 01:20:26 +08:00
..
2026-10-19 22:04:01 +08:00
2026-10-20 00:47:31 +08:00
2026-10-19 22:04:01 +08:00
2026-10-19 22:04:01 +08:00
2026-10-19 22:04:01 +08:00
2026-10-19 22:04:01 +08:00
2026-10-19 22:04:01 +08:00
2026-10-21 05:53:27 +08:00
2026-10-21 05:53:27 +08:00
2026-10-21 05:53:27 +08:00
2026-10-19 22:04:01 +08:00
2026-10-20 00:47:31 +08:00
2026-10-20 00:47:31 +08:00
2026-10-20 01:09:32 +08:00
2026-10-20 18:55:57 +08:00
2026-10-20 18:55:57 +08:00
2026-10-20 18:55:57 +08:00
2026-10-21 00:47:11 +08:00
2026-10-21 17:43:18 +08:00
2026-10-21 17:43:18 +08:00
2026-10-29 17:19:24 +08:00
2026-10-29 17:19:24 +08:00
2026-10-29 17:19:24 +08:00
2026-10-29 17:20:05 +08:00
2026-10-29 17:20:05 +08:00
2026-10-29 17:20:05 +08:00
2026-10-29 17:20:28 +08:00
2026-10-29 17:21:16 +08:00
2026-11-07 16:23:03 +08:00
2026-11-07 20:33:46 +08:00
2026-11-10 04:22:52 +08:00
2026-11-16 02:43:26 +08:00
2026-11-17 01:20:26 +08:00