add indexes and filter the merge

This commit is contained in:
Paul Trowbridge 2025-07-29 03:29:47 -04:00
parent e3b21b0898
commit 35e7ce0f99

View File

@ -26,6 +26,26 @@ CREATE TABLE pricequote.queue (
);
CREATE INDEX idx_osm_stack_merge
ON rlarp.osm_stack (
bill_cust,
ship_cust,
part,
stlc,
dataseg,
qtyord
);
CREATE INDEX idx_queue_merge
ON pricequote.queue (
bill,
ship,
part,
stlc,
v1ds,
vol
);
--DROP PROCEDURE IF EXISTS pricequote.process_queue;
@ -56,6 +76,7 @@ BEGIN
AND o.part IS NOT NULL
AND substring(o.glec, 1, 1) <= '2';
-----------------------------------------------------------------------
-- Step 2: Enrich customer, tier, channel, pack quantity, and level
-----------------------------------------------------------------------
@ -228,7 +249,12 @@ BEGIN
AND o.part = q.part
AND o.stlc = q.stlc
AND o.dataseg = q.v1ds
AND o.qtyord = q.vol;
AND o.qtyord = q.vol
AND o.fs_line = '41010'
AND o.calc_status <> 'CANCELLED'
AND o.version IN ('Actual', 'Forecast', 'Quotes')
AND o.part IS NOT NULL
AND substring(o.glec, 1, 1) <= '2';
-----------------------------------------------------------------------
-- Done