revised run times

This commit is contained in:
Paul Trowbridge 2025-08-28 09:32:32 -04:00
parent ad6d3d60f0
commit a8d83cc042

View File

@ -87,7 +87,7 @@ BEGIN
AND o.version IN ('Actual', 'Forecast', 'Quotes') AND o.version IN ('Actual', 'Forecast', 'Quotes')
AND o.part IS NOT NULL AND o.part IS NOT NULL
AND SUBSTRING(o.glec, 1, 1) <= '2'; AND SUBSTRING(o.glec, 1, 1) <= '2';
-- 2:12 -- 2:12 0:38
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 2) Enrich: chan, tier, cust, pltq, plevel, partgroup (+stlc fix) -- 2) Enrich: chan, tier, cust, pltq, plevel, partgroup (+stlc fix)
@ -129,7 +129,7 @@ BEGIN
plevel = s.plevel, plevel = s.plevel,
partgroup = s.partgroup, partgroup = s.partgroup,
stlc = COALESCE(q.stlc, s.stlc_fix); stlc = COALESCE(q.stlc, s.stlc_fix);
-- 4:51 -- 4:51 0:17
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 3) Scenario fields from item master: part_v1ds, v0ds, orig costs -- 3) Scenario fields from item master: part_v1ds, v0ds, orig costs
@ -149,7 +149,7 @@ BEGIN
END END
FROM "CMS.CUSLG".itemm i0 FROM "CMS.CUSLG".itemm i0
WHERE i0.item = q.part; WHERE i0.item = q.part;
-- 3:21 -- 3:21 0:20
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 4) History: store hist, extract last_* with precedence helper -- 4) History: store hist, extract last_* with precedence helper
@ -187,7 +187,7 @@ BEGIN
AND lp2.partgroup = q2.partgroup AND lp2.partgroup = q2.partgroup
) AS x ) AS x
WHERE q.ctid = x.ctid; WHERE q.ctid = x.ctid;
-- 7:32 -- 7:32 1:31
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 5) Target (requested v1ds): tprice, tmath, volume_range -- 5) Target (requested v1ds): tprice, tmath, volume_range
@ -204,7 +204,7 @@ BEGIN
AND tp.chan = q.chan AND tp.chan = q.chan
AND tp.tier = q.tier AND tp.tier = q.tier
AND FLOOR(q.vol / NULLIF(q.pltq, 0))::INT <@ tp.vol; AND FLOOR(q.vol / NULLIF(q.pltq, 0))::INT <@ tp.vol;
-- 2:51 -- 2:51 0:15
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 6) Target for last_dataseg (tprice_last) -- 6) Target for last_dataseg (tprice_last)
@ -220,7 +220,7 @@ BEGIN
AND tp2.chan = q.chan AND tp2.chan = q.chan
AND tp2.tier = q.tier AND tp2.tier = q.tier
AND FLOOR(q.last_qty / NULLIF(q.pltq, 0))::INT <@ tp2.vol; AND FLOOR(q.last_qty / NULLIF(q.pltq, 0))::INT <@ tp2.vol;
-- 1:26 -- 1:26 0:08
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 7) Cost data for requested v1ds and last_dataseg -- 7) Cost data for requested v1ds and last_dataseg
@ -253,7 +253,7 @@ BEGIN
ON v0l.stlc = q2.stlc AND v0l.v0ds = q2.last_v0ds ON v0l.stlc = q2.stlc AND v0l.v0ds = q2.last_v0ds
) AS s ) AS s
WHERE q.ctid = s.ctid; WHERE q.ctid = s.ctid;
-- 4:15 -- 4:15 0:25
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 8) List price (lowest valid); allow open-ended ranges (vb_to IS NULL) -- 8) List price (lowest valid); allow open-ended ranges (vb_to IS NULL)
@ -283,7 +283,7 @@ BEGIN
listcode = p.jcplcd listcode = p.jcplcd
FROM best_price p FROM best_price p
WHERE q.ctid = p.ctid; WHERE q.ctid = p.ctid;
-- 2:48 -- 2:48 0:18
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 9) Normalize last (when last_dataseg != v1ds) + effective list flags -- 9) Normalize last (when last_dataseg != v1ds) + effective list flags
@ -331,7 +331,7 @@ BEGIN
END, END,
listprice_eff = CASE WHEN q.customized <> '' THEN NULL ELSE q.listprice END, listprice_eff = CASE WHEN q.customized <> '' THEN NULL ELSE q.listprice END,
list_relevance = CASE WHEN q.customized <> '' THEN 'Ignore - Customized' ELSE '' END; list_relevance = CASE WHEN q.customized <> '' THEN 'Ignore - Customized' ELSE '' END;
-- 2:22 -- 2:22 0:23
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 10) Guidance using normalized last + effective list -- 10) Guidance using normalized last + effective list
@ -367,7 +367,7 @@ BEGIN
) a ON TRUE ) a ON TRUE
) s ) s
WHERE q.ctid = s.ctid; WHERE q.ctid = s.ctid;
-- 4:33 -- 4:33 0:39
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 11) Build expl and ui_json identical to single_price_call -- 11) Build expl and ui_json identical to single_price_call
@ -515,7 +515,7 @@ BEGIN
), ),
'data', q.expl 'data', q.expl
); );
-- 7:59 -- 7:59 2:17
-------------------------------------------------------------------- --------------------------------------------------------------------
-- 12) Merge back into matrix (store both expl and ui) -- 12) Merge back into matrix (store both expl and ui)
@ -539,7 +539,7 @@ BEGIN
AND o.version IN ('Actual', 'Forecast', 'Quotes') AND o.version IN ('Actual', 'Forecast', 'Quotes')
AND o.part IS NOT NULL AND o.part IS NOT NULL
AND SUBSTRING(o.glec, 1, 1) <= '2'; AND SUBSTRING(o.glec, 1, 1) <= '2';
-- 14:13 -- 14:13 10:09
RAISE NOTICE 'Queue processing complete.'; RAISE NOTICE 'Queue processing complete.';
END; END;