-- liquibase formatted sql
-- changeset Enson:add_stock_take_round_indexes

-- 1) stocktakerecord：优先按“同一轮次”取记录（避免再用 stockTakeId 列表 + in）
ALTER TABLE `fpsmsdb`.`stocktakerecord`
ADD INDEX `idx_stocktakerecord_round_deleted_wh_lot`
(`stockTakeRoundId`, `deleted`, `warehouseId`, `inventoryLotId`);

-- 2) stock_take_line：给 (stockTakeId, inventoryLotLineId) 的 join / map 提速
ALTER TABLE `fpsmsdb`.`stock_take_line`
ADD INDEX `idx_stocktakeline_stockTakeId_lineId_deleted`
(`stockTakeId`, `inventoryLotLineId`, `deleted`);

-- 3) inventory_lot_line：给 (warehouseId, inventoryLotId) 的库存行筛选提速
ALTER TABLE `fpsmsdb`.`inventory_lot_line`
ADD INDEX `idx_inventorylotline_wh_lot_deleted`
(`warehouseId`, `inventoryLotId`, `deleted`);

