huge increase in run times
This commit is contained in:
parent
c61729e017
commit
42c5900efe
@ -66,6 +66,7 @@ BEGIN
|
|||||||
-- 1) Seed queue from matrix
|
-- 1) Seed queue from matrix
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
DELETE FROM pricequote.queue;
|
DELETE FROM pricequote.queue;
|
||||||
|
-- 1:30
|
||||||
|
|
||||||
INSERT INTO pricequote.queue (bill, ship, part, stlc, v1ds, vol, expl, ui_json)
|
INSERT INTO pricequote.queue (bill, ship, part, stlc, v1ds, vol, expl, ui_json)
|
||||||
SELECT DISTINCT
|
SELECT DISTINCT
|
||||||
@ -84,7 +85,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';
|
||||||
-- 46 seconds
|
-- 2:12
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 2) Enrich: chan, tier, cust, pltq, plevel, partgroup (+stlc fix)
|
-- 2) Enrich: chan, tier, cust, pltq, plevel, partgroup (+stlc fix)
|
||||||
@ -126,7 +127,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);
|
||||||
-- 16 seconds
|
-- 4:51
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 3) Scenario fields from item master: part_v1ds, v0ds, orig costs
|
-- 3) Scenario fields from item master: part_v1ds, v0ds, orig costs
|
||||||
@ -146,7 +147,7 @@ BEGIN
|
|||||||
END
|
END
|
||||||
FROM "CMS.CUSLG".itemm i0
|
FROM "CMS.CUSLG".itemm i0
|
||||||
WHERE i0.item = q.part;
|
WHERE i0.item = q.part;
|
||||||
-- 16 seconds
|
-- 3:21
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 4) History: store hist, extract last_* with precedence helper
|
-- 4) History: store hist, extract last_* with precedence helper
|
||||||
@ -184,7 +185,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;
|
||||||
-- 2 min 3 sec
|
-- 7:32
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 5) Target (requested v1ds): tprice, tmath, volume_range
|
-- 5) Target (requested v1ds): tprice, tmath, volume_range
|
||||||
@ -201,7 +202,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;
|
||||||
-- 22 seconds
|
-- 2:51
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 6) Target for last_dataseg (tprice_last)
|
-- 6) Target for last_dataseg (tprice_last)
|
||||||
@ -217,7 +218,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;
|
||||||
-- 17 sec
|
-- 1:26
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 7) Cost data for requested v1ds and last_dataseg
|
-- 7) Cost data for requested v1ds and last_dataseg
|
||||||
@ -250,7 +251,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;
|
||||||
-- 28 seconds
|
-- 4:15
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 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)
|
||||||
@ -280,7 +281,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;
|
||||||
-- 18 seconds
|
-- 2:48
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 9) Normalize last (when last_dataseg != v1ds) + effective list flags
|
-- 9) Normalize last (when last_dataseg != v1ds) + effective list flags
|
||||||
@ -328,7 +329,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;
|
||||||
-- 21 seconds
|
-- 2:22
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 10) Guidance using normalized last + effective list
|
-- 10) Guidance using normalized last + effective list
|
||||||
@ -352,7 +353,7 @@ BEGIN
|
|||||||
) g ON TRUE
|
) g ON TRUE
|
||||||
) s
|
) s
|
||||||
WHERE q.ctid = s.ctid;
|
WHERE q.ctid = s.ctid;
|
||||||
-- 31 seconds
|
-- 4:33
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 11) Build expl and ui_json identical to single_price_call
|
-- 11) Build expl and ui_json identical to single_price_call
|
||||||
@ -498,7 +499,7 @@ BEGIN
|
|||||||
),
|
),
|
||||||
'data', q.expl
|
'data', q.expl
|
||||||
);
|
);
|
||||||
-- 2 minutes 33 seconds
|
-- 7:59
|
||||||
|
|
||||||
--------------------------------------------------------------------
|
--------------------------------------------------------------------
|
||||||
-- 12) Merge back into matrix (store both expl and ui)
|
-- 12) Merge back into matrix (store both expl and ui)
|
||||||
@ -522,7 +523,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';
|
||||||
-- 9 minutes 35 seconds
|
-- 14:13
|
||||||
|
|
||||||
RAISE NOTICE 'Queue processing complete.';
|
RAISE NOTICE 'Queue processing complete.';
|
||||||
END;
|
END;
|
||||||
|
Loading…
Reference in New Issue
Block a user