WMS_MAIN/database/migrations/20260902100000-add-packing-list-query-index.js

20 lines
666 B
JavaScript
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.

'use strict';
/**
* order.packing.list 慢查询优化配套索引。
* 列表默认按 create_time DESC 排序(_buildListOrder),原 idx_warehouse_id 单列索引
* 命中后需 filesort 全仓库行数(生产实测 33722 行),新增 (warehouse_id, create_time)
* 复合索引消除 filesort,加速默认列表与导出查询。
*/
module.exports = {
async up(queryInterface) {
await queryInterface.addIndex('wms_pack_task', [ 'warehouse_id', 'create_time' ], {
name: 'idx_warehouse_create_time',
});
},
async down(queryInterface) {
await queryInterface.removeIndex('wms_pack_task', 'idx_warehouse_create_time');
},
};