break out base target table with proper index, and create separate refresh script
This commit is contained in:
parent
993a476bea
commit
9a410b82d1
@ -14,28 +14,3 @@ GRANT SELECT, INSERT, UPDATE, DELETE ON pricequote.target_prices TO PUBLIC;
|
|||||||
DROP TABLE IF EXISTS import.core_target;
|
DROP TABLE IF EXISTS import.core_target;
|
||||||
|
|
||||||
CREATE TABLE import.core_target AS (SELECT * FROM pricequote.core_target);
|
CREATE TABLE import.core_target AS (SELECT * FROM pricequote.core_target);
|
||||||
|
|
||||||
WITH
|
|
||||||
expand AS (
|
|
||||||
SELECT
|
|
||||||
c.compset,
|
|
||||||
c.stlc,
|
|
||||||
c.floor,
|
|
||||||
b.ds,
|
|
||||||
b.chan,
|
|
||||||
b.tier,
|
|
||||||
b.vol,
|
|
||||||
b.val,
|
|
||||||
b.price,
|
|
||||||
json_pretty(to_json(b.math)) math
|
|
||||||
FROM
|
|
||||||
pricequote.core_target c
|
|
||||||
LEFT JOIN LATERAL pricequote.build_pricing_path_base (options||jsonb_build_object('entity','Anchor','attr',c.stlc,'val',c.floor,'func','Price')) b ON b.lastflag
|
|
||||||
)
|
|
||||||
-- select count(*) from expand
|
|
||||||
INSERT INTO
|
|
||||||
pricequote.target_prices_base
|
|
||||||
SELECT
|
|
||||||
*
|
|
||||||
FROM
|
|
||||||
expand
|
|
||||||
|
27
tables/rebuild_targets.pg.sql
Normal file
27
tables/rebuild_targets.pg.sql
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
|
||||||
|
DELETE FROM pricequote.target_prices_base;
|
||||||
|
|
||||||
|
WITH
|
||||||
|
expand AS (
|
||||||
|
SELECT
|
||||||
|
c.compset,
|
||||||
|
c.stlc,
|
||||||
|
c.floor,
|
||||||
|
b.ds,
|
||||||
|
b.chan,
|
||||||
|
b.tier,
|
||||||
|
b.vol,
|
||||||
|
b.val,
|
||||||
|
b.price,
|
||||||
|
b.math math
|
||||||
|
FROM
|
||||||
|
pricequote.core_target c
|
||||||
|
LEFT JOIN LATERAL pricequote.build_pricing_path_base (options||jsonb_build_object('entity','Anchor','attr',c.stlc,'val',c.floor,'func','Price')) b ON b.lastflag
|
||||||
|
)
|
||||||
|
-- select count(*) from expand
|
||||||
|
INSERT INTO
|
||||||
|
pricequote.target_prices_base
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM
|
||||||
|
expand;
|
17
tables/target_prices_base.pg.sql
Normal file
17
tables/target_prices_base.pg.sql
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
DROP TABLE pricequote.target_prices_base CASCADE;
|
||||||
|
|
||||||
|
CREATE TABLE pricequote.target_prices_base (
|
||||||
|
compset TEXT NOT NULL,
|
||||||
|
stlc TEXT NOT NULL,
|
||||||
|
floor NUMERIC NOT NULL,
|
||||||
|
ds TEXT NOT NULL,
|
||||||
|
chan TEXT NOT NULL,
|
||||||
|
tier TEXT NOT NULL,
|
||||||
|
vol INT4RANGE NOT NULL,
|
||||||
|
val NUMERIC NOT NULL,
|
||||||
|
price NUMERIC,
|
||||||
|
math TEXT[],
|
||||||
|
PRIMARY KEY (stlc, ds, chan, tier, vol)
|
||||||
|
);
|
||||||
|
|
||||||
|
GRANT SELECT, INSERT, UPDATE, DELETE ON pricequote.target_prices_base TO PUBLIC;
|
@ -8,4 +8,4 @@ SELECT
|
|||||||
,price
|
,price
|
||||||
,to_jsonb(math)::text AS math
|
,to_jsonb(math)::text AS math
|
||||||
FROM
|
FROM
|
||||||
pricequote.target_prices;
|
pricequote.target_prices_base;
|
||||||
|
Loading…
Reference in New Issue
Block a user