pdbench/MayBMS-tpch/urel-ULDB.sql

576 lines
22 KiB
SQL

--set search_path to public,data_s0_01_x0_001_z0_1_p0_25;
------------------------------------------
-- setup trio metadata tables
------------------------------------------
CREATE TABLE trio_tables(tablename name,"type" integer,confbase boolean,istemporary boolean)
WITHOUT OIDS;
CREATE INDEX trio_tables_idx ON trio_tables USING btree (tablename, "type", confbase);
CREATE TABLE trio_tables_lin(tablename name,srctable name)
WITHOUT OIDS;
CREATE INDEX trio_tables_lin_idx ON trio_tables_lin USING btree (tablename, srctable);
CREATE TABLE trio_attribs(tablename name,attrname name,colnum integer,iscertain boolean)
WITHOUT OIDS;
CREATE INDEX trio_attribs_idx ON trio_attribs USING btree (tablename, attrname, colnum);
------------------------------------------------------------------------------------
-- create table wbase holding the pairs cid, lwid as a TRIO base relation
------------------------------------------------------------------------------------
insert into trio_tables values('wbase',0,'t','f');
insert into trio_attribs values('wbase','trio_xid',0,'f');
create table trio_c_wbase(trio_xid integer,trio_alts integer,trio_enc integer) WITHOUT OIDS;
create table trio_u_wbase(trio_xid integer,trio_aid integer) WITHOUT OIDS;
create table trio_lin_wbase(aid integer,disjlin integer,srclin integer,srctable name) WITHOUT OIDS;
insert into trio_c_wbase
select cid as xid, count(*) as trio_alts, count(*) as trio_enc
from w group by cid;
insert into trio_u_wbase
select cid as xid, aid
from w;
create or replace view wbase as
select c.trio_xid, u.trio_aid, c.trio_alts, c.trio_enc, NULL::numeric AS trio_conf
FROM trio_u_wbase u, trio_c_wbase c
WHERE u.trio_xid = c.trio_xid
ORDER BY c.trio_xid;
CREATE INDEX trio_lin_wbase_idx
ON trio_lin_wbase
USING btree
(aid, srctable, srclin, disjlin);
CREATE INDEX trio_c_wbase_xid_idx
ON trio_c_wbase
USING btree
(trio_xid);
CREATE INDEX trio_u_wbase_xid_idx
ON trio_u_wbase
USING btree
(trio_xid);
------------------------------------------
-- nation
------------------------------------------
insert into trio_tables values('tnation',0,'f','f');
insert into trio_attribs values('tnation','n_nationkey',0,'f');
insert into trio_attribs values('tnation','n_name',1,'f');
insert into trio_attribs values('tnation','n_regionkey',2,'f');
insert into trio_attribs values('tnation','n_comment',3,'f');
insert into trio_tables_lin values('tnation','wbase');
create table trio_c_tnation(trio_xid integer,trio_alts integer,trio_enc integer) WITHOUT OIDS;
create table trio_u_tnation(n_nationkey integer,n_name character(25),n_regionkey integer,n_comment character varying(152),trio_xid integer,trio_aid integer) WITHOUT OIDS;
create table trio_lin_tnation(aid integer,disjlin integer,srclin integer,srctable name) WITHOUT OIDS;
-- populate tnation
insert into trio_c_tnation
select tid as xid, count(*) as trio_alts, count(*) as trio_enc
from nation group by tid;
insert into trio_u_tnation
select n_nationkey, n_name, n_regionkey, n_comment, tid as trio_xid, oid as trio_aid
from nation;
insert into trio_lin_tnation
select oid as aid, oid as disjlin, w.aid as srclin, 'wbase'
from nation, w
where nation.c1 = w.cid and nation.w1 = w.lwid or
nation.c2 = w.cid and nation.w2 = w.lwid or
nation.c3 = w.cid and nation.w3 = w.lwid or
nation.c4 = w.cid and nation.w4 = w.lwid;
create or replace view tnation as
select u.n_nationkey,u.n_name,u.n_regionkey,u.n_comment, c.trio_xid, u.trio_aid, c.trio_alts, c.trio_enc, NULL::numeric AS trio_conf
FROM trio_u_tnation u, trio_c_tnation c
WHERE u.trio_xid = c.trio_xid
ORDER BY c.trio_xid;
CREATE INDEX trio_lin_tnation_idx
ON trio_lin_tnation
USING btree
(aid, srctable, srclin, disjlin);
CREATE INDEX trio_c_tnation_xid_idx
ON trio_c_tnation
USING btree
(trio_xid);
CREATE INDEX trio_u_tnation_xid_idx
ON trio_u_tnation
USING btree
(trio_xid);
------------------------------------------
-- region
------------------------------------------
insert into trio_tables values('tregion',0,'f','f');
insert into trio_attribs values('tregion','r_regionkey',0,'f');
insert into trio_attribs values('tregion','r_name',1,'f');
insert into trio_attribs values('tregion','r_comment',2,'f');
insert into trio_tables_lin values('tregion','wbase');
create table trio_c_tregion(trio_xid integer,trio_alts integer,trio_enc integer) WITHOUT OIDS;
create table trio_u_tregion(r_regionkey integer,r_name character(25),r_comment character varying(152),trio_xid integer,trio_aid integer) WITHOUT OIDS;
create table trio_lin_tregion(aid integer,disjlin integer,srclin integer,srctable name) WITHOUT OIDS;
-- populate tregion
insert into trio_c_tregion
select tid as xid, count(*) as trio_alts, count(*) as trio_enc
from region group by tid;
insert into trio_u_tregion
select r_regionkey, r_name, r_comment, tid as trio_xid, oid as trio_aid
from region;
insert into trio_lin_tregion
select oid as aid, oid as disjlin, w.aid as srclin, 'wbase'
from region, w
where region.c1 = w.cid and region.w1 = w.lwid or
region.c2 = w.cid and region.w2 = w.lwid or
region.c3 = w.cid and region.w3 = w.lwid;
create or replace view tregion as
select u.r_regionkey,u.r_name,u.r_comment, c.trio_xid, u.trio_aid, c.trio_alts, c.trio_enc, NULL::numeric AS trio_conf
FROM trio_u_tregion u, trio_c_tregion c
WHERE u.trio_xid = c.trio_xid
ORDER BY c.trio_xid;
CREATE INDEX trio_lin_tregion_idx
ON trio_lin_tregion
USING btree
(aid, srctable, srclin, disjlin);
CREATE INDEX trio_c_tregion_xid_idx
ON trio_c_tregion
USING btree
(trio_xid);
CREATE INDEX trio_u_tregion_xid_idx
ON trio_u_tregion
USING btree
(trio_xid);
------------------------------------------
-- part
------------------------------------------
insert into trio_tables values('tpart',0,'f','f');
insert into trio_attribs values('tpart','p_partkey',0,'f');
insert into trio_attribs values('tpart','p_name',1,'f');
insert into trio_attribs values('tpart','p_mfgr',2,'f');
insert into trio_attribs values('tpart','p_brand',3,'f');
insert into trio_attribs values('tpart','p_type',4,'f');
insert into trio_attribs values('tpart','p_size',5,'f');
insert into trio_attribs values('tpart','p_container',6,'f');
insert into trio_attribs values('tpart','p_retailprice',7,'f');
insert into trio_attribs values('tpart','p_comment',8,'f');
insert into trio_tables_lin values('tpart','wbase');
create table trio_c_tpart(trio_xid integer,trio_alts integer,trio_enc integer) WITHOUT OIDS;
create table trio_u_tpart(p_partkey integer,p_name character varying(55),p_mfgr character(25),p_brand character(10),p_type character varying(25),
p_size integer,p_container character(10),p_retailprice numeric(15,2),p_comment character varying(23),trio_xid integer,trio_aid integer) WITHOUT OIDS;
create table trio_lin_tpart(aid integer,disjlin integer,srclin integer,srctable name) WITHOUT OIDS;
-- populate tpart
insert into trio_c_tpart
select tid as xid, count(*) as trio_alts, count(*) as trio_enc
from part group by tid;
insert into trio_u_tpart
select p_partkey, p_name, p_mfgr, p_brand, p_type, p_size, p_container, p_retailprice, p_comment, tid as trio_xid, oid as trio_aid
from part;
insert into trio_lin_tpart
select oid as aid, oid as disjlin, w.aid as srclin, 'wbase'
from part, w
where part.c1 = w.cid and part.w1 = w.lwid or
part.c2 = w.cid and part.w2 = w.lwid or
part.c3 = w.cid and part.w3 = w.lwid or
part.c4 = w.cid and part.w4 = w.lwid or
part.c5 = w.cid and part.w5 = w.lwid or
part.c6 = w.cid and part.w6 = w.lwid or
part.c7 = w.cid and part.w7 = w.lwid or
part.c8 = w.cid and part.w8 = w.lwid or
part.c9 = w.cid and part.w9 = w.lwid;
create or replace view tpart as
select u.p_partkey, u.p_name, u.p_mfgr, u.p_brand, u.p_type, u.p_size, u.p_container, u.p_retailprice, u.p_comment,
c.trio_xid, u.trio_aid, c.trio_alts, c.trio_enc, NULL::numeric AS trio_conf
FROM trio_u_tpart u, trio_c_tpart c
WHERE u.trio_xid = c.trio_xid
ORDER BY c.trio_xid;
CREATE INDEX trio_lin_tpart_idx
ON trio_lin_tpart
USING btree
(aid, srctable, srclin, disjlin);
CREATE INDEX trio_c_tpart_xid_idx
ON trio_c_tpart
USING btree
(trio_xid);
CREATE INDEX trio_u_tpart_xid_idx
ON trio_u_tpart
USING btree
(trio_xid);
------------------------------------------
-- supplier
------------------------------------------
insert into trio_tables values('tsupplier',0,'f','f');
insert into trio_attribs values('tsupplier','s_suppkey',0,'f');
insert into trio_attribs values('tsupplier','s_name',1,'f');
insert into trio_attribs values('tsupplier','s_address',2,'f');
insert into trio_attribs values('tsupplier','s_nationkey',3,'f');
insert into trio_attribs values('tsupplier','s_phone',4,'f');
insert into trio_attribs values('tsupplier','s_acctbal',5,'f');
insert into trio_attribs values('tsupplier','s_comment',6,'f');
insert into trio_tables_lin values('tsupplier','wbase');
create table trio_c_tsupplier(trio_xid integer,trio_alts integer,trio_enc integer) WITHOUT OIDS;
create table trio_u_tsupplier(s_suppkey integer,s_name character(25),s_address character varying(40),s_nationkey integer,s_phone character(15),
s_acctbal numeric(15,2),s_comment character varying(101),
trio_xid integer,trio_aid integer) WITHOUT OIDS;
create table trio_lin_tsupplier(aid integer,disjlin integer,srclin integer,srctable name) WITHOUT OIDS;
-- populate tsupplier
insert into trio_c_tsupplier
select tid as xid, count(*) as trio_alts, count(*) as trio_enc
from supplier group by tid;
insert into trio_u_tsupplier
select s_suppkey, s_name, s_address, s_nationkey, s_phone, s_acctbal, s_comment, tid as trio_xid, oid as trio_aid
from supplier;
insert into trio_lin_tsupplier
select oid as aid, oid as disjlin, w.aid as srclin, 'wbase'
from supplier, w
where supplier.c1 = w.cid and supplier.w1 = w.lwid or
supplier.c2 = w.cid and supplier.w2 = w.lwid or
supplier.c3 = w.cid and supplier.w3 = w.lwid or
supplier.c4 = w.cid and supplier.w4 = w.lwid or
supplier.c5 = w.cid and supplier.w5 = w.lwid or
supplier.c6 = w.cid and supplier.w6 = w.lwid or
supplier.c7 = w.cid and supplier.w7 = w.lwid;
create or replace view tsupplier as
select u.s_suppkey, u.s_name, u.s_address, u.s_nationkey, u.s_phone, u.s_acctbal, u.s_comment,
c.trio_xid, u.trio_aid, c.trio_alts, c.trio_enc, NULL::numeric AS trio_conf
FROM trio_u_tsupplier u, trio_c_tsupplier c
WHERE u.trio_xid = c.trio_xid
ORDER BY c.trio_xid;
CREATE INDEX trio_lin_tsupplier_idx
ON trio_lin_tsupplier
USING btree
(aid, srctable, srclin, disjlin);
CREATE INDEX trio_c_tsupplier_xid_idx
ON trio_c_tsupplier
USING btree
(trio_xid);
CREATE INDEX trio_u_tsupplier_xid_idx
ON trio_u_tsupplier
USING btree
(trio_xid);
------------------------------------------
-- partsupp
------------------------------------------
insert into trio_tables values('tpartsupp',0,'f','f');
insert into trio_attribs values('tpartsupp','ps_partkey',0,'f');
insert into trio_attribs values('tpartsupp','ps_suppkey',1,'f');
insert into trio_attribs values('tpartsupp','ps_availqty',2,'f');
insert into trio_attribs values('tpartsupp','ps_supplycost',3,'f');
insert into trio_attribs values('tpartsupp','ps_comment',4,'f');
insert into trio_tables_lin values('tpartsupp','wbase');
create table trio_c_tpartsupp(trio_xid integer,trio_alts integer,trio_enc integer) WITHOUT OIDS;
create table trio_u_tpartsupp(ps_partkey integer, ps_suppkey integer,ps_availqty integer,
ps_supplycost numeric(15,2),ps_comment character varying(199),
trio_xid integer,trio_aid integer) WITHOUT OIDS;
create table trio_lin_tpartsupp(aid integer,disjlin integer,srclin integer,srctable name) WITHOUT OIDS;
-- populate tpartsupp
insert into trio_c_tpartsupp
select tid as xid, count(*) as trio_alts, count(*) as trio_enc
from partsupp group by tid;
insert into trio_u_tpartsupp
select ps_partkey, ps_suppkey, ps_availqty, ps_supplycost, ps_comment, tid as trio_xid, oid as trio_aid
from partsupp;
insert into trio_lin_tpartsupp
select oid as aid, oid as disjlin, w.aid as srclin, 'wbase'
from partsupp, w
where partsupp.c1 = w.cid and partsupp.w1 = w.lwid or
partsupp.c2 = w.cid and partsupp.w2 = w.lwid or
partsupp.c3 = w.cid and partsupp.w3 = w.lwid or
partsupp.c4 = w.cid and partsupp.w4 = w.lwid or
partsupp.c5 = w.cid and partsupp.w5 = w.lwid;
create or replace view tpartsupp as
select ps_partkey, ps_suppkey, ps_availqty, ps_supplycost, ps_comment,
c.trio_xid, u.trio_aid, c.trio_alts, c.trio_enc, NULL::numeric AS trio_conf
FROM trio_u_tpartsupp u, trio_c_tpartsupp c
WHERE u.trio_xid = c.trio_xid
ORDER BY c.trio_xid;
CREATE INDEX trio_lin_tpartsupp_idx
ON trio_lin_tpartsupp
USING btree
(aid, srctable, srclin, disjlin);
CREATE INDEX trio_c_tpartsupp_xid_idx
ON trio_c_tpartsupp
USING btree
(trio_xid);
CREATE INDEX trio_u_tpartsupp_xid_idx
ON trio_u_tpartsupp
USING btree
(trio_xid);
------------------------------------------
-- customer
------------------------------------------
insert into trio_tables values('tcustomer',0,'f','f');
insert into trio_attribs values('tcustomer','c_custkey',0,'f');
insert into trio_attribs values('tcustomer','c_name',1,'f');
insert into trio_attribs values('tcustomer','c_address',2,'f');
insert into trio_attribs values('tcustomer','c_nationkey',3,'f');
insert into trio_attribs values('tcustomer','c_phone',4,'f');
insert into trio_attribs values('tcustomer','c_acctbal',5,'f');
insert into trio_attribs values('tcustomer','c_mktsegment',6,'f');
insert into trio_attribs values('tcustomer','c_comment',7,'f');
insert into trio_tables_lin values('tcustomer','wbase');
create table trio_c_tcustomer(trio_xid integer,trio_alts integer,trio_enc integer) WITHOUT OIDS;
create table trio_u_tcustomer(c_custkey integer,c_name character varying(25),c_address character varying(40),c_nationkey integer,
c_phone character(15),c_acctbal numeric(15,2),c_mktsegment character(10),c_comment character varying(117),
trio_xid integer,trio_aid integer) WITHOUT OIDS;
create table trio_lin_tcustomer(aid integer,disjlin integer,srclin integer,srctable name) WITHOUT OIDS;
-- populate tcustomer
insert into trio_c_tcustomer
select tid as xid, count(*) as trio_alts, count(*) as trio_enc
from customer group by tid;
insert into trio_u_tcustomer
select c_custkey, c_name, c_address, c_nationkey, c_phone, c_acctbal, c_mktsegment, c_comment, tid as trio_xid, oid as trio_aid
from customer;
insert into trio_lin_tcustomer
select oid as aid, oid as disjlin, w.aid as srclin, 'wbase'
from customer, w
where customer.c1 = w.cid and customer.w1 = w.lwid or
customer.c2 = w.cid and customer.w2 = w.lwid or
customer.c3 = w.cid and customer.w3 = w.lwid or
customer.c4 = w.cid and customer.w4 = w.lwid or
customer.c5 = w.cid and customer.w5 = w.lwid or
customer.c6 = w.cid and customer.w6 = w.lwid or
customer.c7 = w.cid and customer.w7 = w.lwid or
customer.c8 = w.cid and customer.w8 = w.lwid;
create or replace view tcustomer as
select u.c_custkey, u.c_name, u.c_address, u.c_nationkey, u.c_phone, u.c_acctbal, u.c_mktsegment, u.c_comment,
c.trio_xid, u.trio_aid, c.trio_alts, c.trio_enc, NULL::numeric AS trio_conf
FROM trio_u_tcustomer u, trio_c_tcustomer c
WHERE u.trio_xid = c.trio_xid
ORDER BY c.trio_xid;
CREATE INDEX trio_lin_tcustomer_idx
ON trio_lin_tcustomer
USING btree
(aid, srctable, srclin, disjlin);
CREATE INDEX trio_c_tcustomer_xid_idx
ON trio_c_tcustomer
USING btree
(trio_xid);
CREATE INDEX trio_u_tcustomer_xid_idx
ON trio_u_tcustomer
USING btree
(trio_xid);
------------------------------------------
-- orders
------------------------------------------
insert into trio_tables values('torders',0,'f','f');
insert into trio_attribs values('torders','o_orderkey',0,'f');
insert into trio_attribs values('torders','o_custkey',1,'f');
insert into trio_attribs values('torders','o_orderstatus',2,'f');
insert into trio_attribs values('torders','o_totalprice',3,'f');
insert into trio_attribs values('torders','o_orderdate',4,'f');
insert into trio_attribs values('torders','o_orderpriority',5,'f');
insert into trio_attribs values('torders','o_clerk',6,'f');
insert into trio_attribs values('torders','o_shippriority',7,'f');
insert into trio_attribs values('torders','o_comment',8,'f');
insert into trio_tables_lin values('torders','wbase');
create table trio_c_torders(trio_xid integer,trio_alts integer,trio_enc integer) WITHOUT OIDS;
create table trio_u_torders(o_orderkey integer,o_custkey integer,o_orderstatus character(1),o_totalprice numeric(15,2),
o_orderdate date,o_orderpriority character(15),o_clerk character(15),o_shippriority integer,o_comment character varying(79),
trio_xid integer,trio_aid integer) WITHOUT OIDS;
create table trio_lin_torders(aid integer,disjlin integer,srclin integer,srctable name) WITHOUT OIDS;
-- populate torders
insert into trio_c_torders
select tid as xid, count(*) as trio_alts, count(*) as trio_enc
from orders group by tid;
insert into trio_u_torders
select o_orderkey, o_custkey, o_orderstatus, o_totalprice, o_orderdate, o_orderpriority, o_clerk, o_shippriority, o_comment, tid as trio_xid, oid as trio_aid
from orders;
insert into trio_lin_torders
select oid as aid, oid as disjlin, w.aid as srclin, 'wbase'
from orders, w
where orders.c1 = w.cid and orders.w1 = w.lwid or
orders.c2 = w.cid and orders.w2 = w.lwid or
orders.c3 = w.cid and orders.w3 = w.lwid or
orders.c4 = w.cid and orders.w4 = w.lwid or
orders.c5 = w.cid and orders.w5 = w.lwid or
orders.c6 = w.cid and orders.w6 = w.lwid or
orders.c7 = w.cid and orders.w7 = w.lwid or
orders.c8 = w.cid and orders.w8 = w.lwid or
orders.c9 = w.cid and orders.w9 = w.lwid;
create or replace view torders as
select u.o_orderkey, u.o_custkey, u.o_orderstatus, u.o_totalprice, u.o_orderdate, u.o_orderpriority, u.o_clerk, u.o_shippriority, u.o_comment,
c.trio_xid, u.trio_aid, c.trio_alts, c.trio_enc, NULL::numeric AS trio_conf
FROM trio_u_torders u, trio_c_torders c
WHERE u.trio_xid = c.trio_xid
ORDER BY c.trio_xid;
CREATE INDEX trio_lin_torders_idx
ON trio_lin_torders
USING btree
(aid, srctable, srclin, disjlin);
CREATE INDEX trio_c_torders_xid_idx
ON trio_c_torders
USING btree
(trio_xid);
CREATE INDEX trio_u_torders_xid_idx
ON trio_u_torders
USING btree
(trio_xid);
------------------------------------------
-- lineitem
------------------------------------------
insert into trio_tables values('tlineitem',0,'f','f');
insert into trio_attribs values('tlineitem','l_orderkey',0,'f');
insert into trio_attribs values('tlineitem','l_partkey',1,'f');
insert into trio_attribs values('tlineitem','l_suppkey',2,'f');
insert into trio_attribs values('tlineitem','l_linenumber',3,'f');
insert into trio_attribs values('tlineitem','l_quantity',4,'f');
insert into trio_attribs values('tlineitem','l_extendedprice',5,'f');
insert into trio_attribs values('tlineitem','l_discount',6,'f');
insert into trio_attribs values('tlineitem','l_tax',7,'f');
insert into trio_attribs values('tlineitem','l_returnflag',8,'f');
insert into trio_attribs values('tlineitem','l_linestatus',9,'f');
insert into trio_attribs values('tlineitem','l_shipdate',10,'f');
insert into trio_attribs values('tlineitem','l_commitdate',11,'f');
insert into trio_attribs values('tlineitem','l_receiptdate',12,'f');
insert into trio_attribs values('tlineitem','l_shipinstruct',13,'f');
insert into trio_attribs values('tlineitem','l_shipmode',14,'f');
insert into trio_attribs values('tlineitem','l_comment',15,'f');
insert into trio_tables_lin values('tlineitem','wbase');
create table trio_c_tlineitem(trio_xid integer,trio_alts integer,trio_enc integer) WITHOUT OIDS;
create table trio_u_tlineitem(l_orderkey integer,l_partkey integer,l_suppkey integer,l_linenumber integer,
l_quantity numeric(15,2),l_extendedprice numeric(15,2),l_discount numeric(15,2),l_tax numeric(15,2),
l_returnflag character(1),l_linestatus character(1),l_shipdate date,l_commitdate date,l_receiptdate date,
l_shipinstruct character(25),l_shipmode character(10),l_comment character varying(44),
trio_xid integer,trio_aid integer) WITHOUT OIDS;
create table trio_lin_tlineitem(aid integer,disjlin integer,srclin integer,srctable name) WITHOUT OIDS;
-- populate tlineitem
insert into trio_c_tlineitem
select tid as xid, count(*) as trio_alts, count(*) as trio_enc
from lineitem group by tid;
insert into trio_u_tlineitem
select l_orderkey,l_partkey,l_suppkey,l_linenumber,l_quantity,l_extendedprice,l_discount,l_tax,l_returnflag,
l_linestatus,l_shipdate,l_commitdate,l_receiptdate,l_shipinstruct,l_shipmode,l_comment, tid as trio_xid, oid as trio_aid
from lineitem;
insert into trio_lin_tlineitem
select oid as aid, oid as disjlin, w.aid as srclin, 'wbase'
from lineitem, w
where lineitem.c1 = w.cid and lineitem.w1 = w.lwid or
lineitem.c2 = w.cid and lineitem.w2 = w.lwid or
lineitem.c3 = w.cid and lineitem.w3 = w.lwid or
lineitem.c4 = w.cid and lineitem.w4 = w.lwid or
lineitem.c5 = w.cid and lineitem.w5 = w.lwid or
lineitem.c6 = w.cid and lineitem.w6 = w.lwid or
lineitem.c7 = w.cid and lineitem.w7 = w.lwid or
lineitem.c8 = w.cid and lineitem.w8 = w.lwid or
lineitem.c9 = w.cid and lineitem.w9 = w.lwid or
lineitem.c10 = w.cid and lineitem.w10 = w.lwid or
lineitem.c11 = w.cid and lineitem.w11 = w.lwid or
lineitem.c12 = w.cid and lineitem.w12 = w.lwid or
lineitem.c13 = w.cid and lineitem.w13 = w.lwid or
lineitem.c14 = w.cid and lineitem.w14 = w.lwid or
lineitem.c15 = w.cid and lineitem.w15 = w.lwid or
lineitem.c16 = w.cid and lineitem.w8 = w.lwid;
create or replace view tlineitem as
select u.l_orderkey,u.l_partkey,u.l_suppkey,u.l_linenumber,u.l_quantity,u.l_extendedprice,u.l_discount,u.l_tax,u.l_returnflag,
u.l_linestatus,u.l_shipdate,u.l_commitdate,u.l_receiptdate,u.l_shipinstruct,u.l_shipmode,u.l_comment,
c.trio_xid, u.trio_aid, c.trio_alts, c.trio_enc, NULL::numeric AS trio_conf
FROM trio_u_tlineitem u, trio_c_tlineitem c
WHERE u.trio_xid = c.trio_xid
ORDER BY c.trio_xid;
CREATE INDEX trio_lin_tlineitem_idx
ON trio_lin_tlineitem
USING btree
(aid, srctable, srclin, disjlin);
CREATE INDEX trio_c_tlineitem_xid_idx
ON trio_c_tlineitem
USING btree
(trio_xid);
CREATE INDEX trio_u_tlineitem_xid_idx
ON trio_u_tlineitem
USING btree
(trio_xid);