From 35e7ce0f990da055858195d323371757884d25cd Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Tue, 29 Jul 2025 03:29:47 -0400 Subject: [PATCH] add indexes and filter the merge --- new_targets/scripts/matrix_guidance.pg.sql | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/new_targets/scripts/matrix_guidance.pg.sql b/new_targets/scripts/matrix_guidance.pg.sql index e9e96aa..70a445d 100644 --- a/new_targets/scripts/matrix_guidance.pg.sql +++ b/new_targets/scripts/matrix_guidance.pg.sql @@ -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