CREATE INDEX borraForzaTraslado ON nota_bodega(tipo, bodega_id, traslado_forza_ok);
CREATE INDEX borraForzaTrasladoOrigen ON nota_bodega(tipo, origen_id, traslado_forza_ok);
CREATE INDEX verificacionXbodega ON nota_bodega_verificacion(bodega_id); -- 9sec virgoma
CREATE INDEX verificacionXbodega ON nota_bodega_verificacion_items(bodega_id); -- 4sec virgoma
CREATE INDEX itemsXbodega ON nota_bodega_items(bodega_id); -- 4sec virgoma

ALTER TABLE nota_bodega_verificacion_hist -- 2.8 sec
    ADD COLUMN bodega_id_idx VARCHAR(32) GENERATED ALWAYS AS (JSON_UNQUOTE(record->"$.bodega_id")) STORED;
CREATE INDEX idx_bodega_id ON nota_bodega_verificacion_hist (bodega_id_idx);

ALTER TABLE nota_bodega_hist -- 45 sec
    ADD COLUMN bodega_id_idx VARCHAR(32) GENERATED ALWAYS AS (JSON_UNQUOTE(record->"$.bodega_id")) STORED;
CREATE INDEX idx_bodega_id ON nota_bodega_hist (bodega_id_idx);

ALTER TABLE nota_bodega_items_log ADD COLUMN _bodega_id VARCHAR(32) AS (LEFT(producto_bodega_id, 32)) STORED;
CREATE INDEX nota_bodega_items_log_bodega ON nota_bodega_items_log(_bodega_id);
