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