forked from huawei/openGauss-server
604 lines
28 KiB
Plaintext
604 lines
28 KiB
Plaintext
----
|
|
--- Create Talbe
|
|
----
|
|
CREATE SCHEMA DISABLE_VECTOR_ENGINE;
|
|
SET CURRENT_SCHEMA=DISABLE_VECTOR_ENGINE;
|
|
SET ENABLE_VECTOR_ENGINE = OFF;
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01
|
|
(
|
|
DEPNAME VARCHAR,
|
|
EMPNO BIGINT,
|
|
SALARY INT,
|
|
ENROLL DATE,
|
|
TIMESET TIMETZ)
|
|
WITH(ORIENTATION = COLUMN);
|
|
CREATE INDEX IDX_TABLE_01 ON DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01(DEPNAME);
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.VECTOR_TABLE_02
|
|
(
|
|
DEPNAME VARCHAR,
|
|
SALARY INT,
|
|
ENROLL DATE)
|
|
WITH(ORIENTATION = COLUMN);
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.VECTOR_TABLE_03
|
|
(
|
|
DEPNAME VARCHAR,
|
|
SALARY INT,
|
|
ENROLL DATE)
|
|
WITH(ORIENTATION = COLUMN)
|
|
PARTITION BY RANGE(SALARY)
|
|
(
|
|
PARTITION SALARY1 VALUES LESS THAN(2000),
|
|
PARTITION SALARY2 VALUES LESS THAN(3000)
|
|
);
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.ROW_TABLE_01(DEPNAME VARCHAR, SALARY INT, ENROLL DATE);
|
|
-- PartIterator
|
|
EXPLAIN (COSTS OFF) SELECT DISTINCT DEPNAME FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_03;
|
|
QUERY PLAN
|
|
--------------------------------------------------------------
|
|
HashAggregate
|
|
Group By Key: depname
|
|
-> Partition Iterator
|
|
Iterations: 2
|
|
-> Row Adapter
|
|
-> Partitioned CStore Scan on vector_table_03
|
|
Selected Partitions: 1..2
|
|
(7 rows)
|
|
|
|
-- ModifyTable
|
|
EXPLAIN (COSTS OFF) INSERT INTO DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01 SELECT * FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01;
|
|
QUERY PLAN
|
|
--------------------------------------------
|
|
Row Adapter
|
|
-> Vector Insert on vector_table_01
|
|
-> CStore Scan on vector_table_01
|
|
(3 rows)
|
|
|
|
EXPLAIN (COSTS OFF) INSERT INTO DISABLE_VECTOR_ENGINE.ROW_TABLE_01 SELECT * FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_02;
|
|
QUERY PLAN
|
|
--------------------------------------------
|
|
Insert on row_table_01
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_02
|
|
(3 rows)
|
|
|
|
-- Append, Result
|
|
EXPLAIN (COSTS OFF) SELECT DEPNAME FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01 UNION ALL SELECT DEPNAME FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01;
|
|
QUERY PLAN
|
|
--------------------------------------------------
|
|
Result
|
|
-> Append
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_01
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_01
|
|
(6 rows)
|
|
|
|
-- SetOp
|
|
EXPLAIN (COSTS OFF) SELECT DEPNAME FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01 EXCEPT ALL SELECT DEPNAME FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01;
|
|
QUERY PLAN
|
|
--------------------------------------------------------
|
|
HashSetOp Except All
|
|
-> Append
|
|
-> Subquery Scan on "*SELECT* 1"
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_01
|
|
-> Subquery Scan on "*SELECT* 2"
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_01
|
|
(8 rows)
|
|
|
|
-- Group, Unique, CStore Index Scan
|
|
EXPLAIN (COSTS OFF) SELECT DISTINCT DEPNAME FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01 GROUP BY DEPNAME;
|
|
QUERY PLAN
|
|
--------------------------------------------------
|
|
HashAggregate
|
|
Group By Key: depname
|
|
-> HashAggregate
|
|
Group By Key: depname
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_01
|
|
(6 rows)
|
|
|
|
SET ENABLE_SEQSCAN = OFF;
|
|
SET ENABLE_HASHAGG = OFF;
|
|
EXPLAIN (COSTS OFF) SELECT DISTINCT DEPNAME FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01;
|
|
QUERY PLAN
|
|
--------------------------------------------------------------------------------
|
|
Unique
|
|
-> Sort
|
|
Sort Key: depname
|
|
-> Row Adapter
|
|
-> CStore Index Only Scan using idx_table_01 on vector_table_01
|
|
(5 rows)
|
|
|
|
RESET ENABLE_SEQSCAN;
|
|
RESET ENABLE_HASHAGG;
|
|
-- LockRows
|
|
EXPLAIN (COSTS OFF) SELECT * FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01 FOR UPDATE;
|
|
ERROR: SELECT FOR UPDATE/SHARE/NO KEY UPDATE/KEY SHARE cannot be used with column table "vector_table_01"
|
|
-- CteScan
|
|
-- HashJoin, MergeJoin, NestLoop, Materialize
|
|
EXPLAIN (COSTS OFF) SELECT * FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01 T1, DISABLE_VECTOR_ENGINE.VECTOR_TABLE_02 T2 WHERE T1.DEPNAME=T2.DEPNAME;
|
|
QUERY PLAN
|
|
--------------------------------------------------------
|
|
Hash Join
|
|
Hash Cond: ((t2.depname)::text = (t1.depname)::text)
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_02 t2
|
|
-> Hash
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_01 t1
|
|
(7 rows)
|
|
|
|
SET ENABLE_HASHJOIN = OFF;
|
|
EXPLAIN (COSTS OFF) SELECT * FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01 T1, DISABLE_VECTOR_ENGINE.VECTOR_TABLE_02 T2 WHERE T1.DEPNAME=T2.DEPNAME;
|
|
QUERY PLAN
|
|
---------------------------------------------------------
|
|
Merge Join
|
|
Merge Cond: ((t1.depname)::text = (t2.depname)::text)
|
|
-> Sort
|
|
Sort Key: t1.depname
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_01 t1
|
|
-> Sort
|
|
Sort Key: t2.depname
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_02 t2
|
|
(10 rows)
|
|
|
|
SET ENABLE_MERGEJOIN = OFF;
|
|
EXPLAIN (COSTS OFF) SELECT * FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01 T1, DISABLE_VECTOR_ENGINE.VECTOR_TABLE_02 T2 WHERE T1.DEPNAME=T2.DEPNAME;
|
|
QUERY PLAN
|
|
----------------------------------------------------------
|
|
Nested Loop
|
|
Join Filter: ((t1.depname)::text = (t2.depname)::text)
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_02 t2
|
|
-> Materialize
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_01 t1
|
|
(7 rows)
|
|
|
|
RESET ENABLE_HASHJOIN;
|
|
RESET ENABLE_MERGEJOIN;
|
|
-- MergeAppend
|
|
EXPLAIN (COSTS OFF) (SELECT DEPNAME FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01 ORDER BY DEPNAME ) UNION ALL (SELECT DEPNAME FROM DISABLE_VECTOR_ENGINE.VECTOR_TABLE_02 ORDER BY DEPNAME) ORDER BY 1;
|
|
QUERY PLAN
|
|
--------------------------------------------------------
|
|
Sort
|
|
Sort Key: vector_table_01.depname
|
|
-> Result
|
|
-> Append
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_01
|
|
-> Row Adapter
|
|
-> CStore Scan on vector_table_02
|
|
(8 rows)
|
|
|
|
-- Explain bogus varno bug
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.T1(A INT, B INT);
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.T2(A INT, B INT) ;
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.COL_TABLE(A INT, B INT) WITH (ORIENTATION=COLUMN);
|
|
EXPLAIN (COSTS OFF, VERBOSE ON) INSERT INTO DISABLE_VECTOR_ENGINE.COL_TABLE SELECT P.A,P.B FROM DISABLE_VECTOR_ENGINE.T1 P INNER JOIN DISABLE_VECTOR_ENGINE.T2 Q ON( P.A=Q.A);
|
|
QUERY PLAN
|
|
----------------------------------------------------------------------
|
|
Row Adapter
|
|
-> Vector Insert on disable_vector_engine.col_table
|
|
-> Vector Adapter
|
|
Output: p.a, p.b
|
|
-> Hash Join
|
|
Output: p.a, p.b
|
|
Hash Cond: (p.a = q.a)
|
|
-> Seq Scan on disable_vector_engine.t1 p
|
|
Output: p.a, p.b
|
|
-> Hash
|
|
Output: q.a
|
|
-> Seq Scan on disable_vector_engine.t2 q
|
|
Output: q.a
|
|
(13 rows)
|
|
|
|
RESET ENABLE_VECTOR_ENGINE;
|
|
-- Agg and Window functions not not yet implemented in Vector Engine, fallback
|
|
EXPLAIN (COSTS OFF, VERBOSE ON) SELECT BOOL_AND(SALARY) + 1 FROM VECTOR_TABLE_01;
|
|
QUERY PLAN
|
|
------------------------------------------------------------------
|
|
Aggregate
|
|
Output: ((bool_and((salary)::boolean))::bigint + 1)
|
|
-> Row Adapter
|
|
Output: salary
|
|
-> CStore Scan on disable_vector_engine.vector_table_01
|
|
Output: salary
|
|
(6 rows)
|
|
|
|
EXPLAIN (COSTS OFF, VERBOSE ON) SELECT DEPNAME FROM VECTOR_TABLE_01 GROUP BY DEPNAME HAVING STRING_AGG(SALARY,';') IS NOT NULL;
|
|
QUERY PLAN
|
|
-------------------------------------------------------------------------------
|
|
HashAggregate
|
|
Output: depname
|
|
Group By Key: vector_table_01.depname
|
|
Filter: (string_agg((vector_table_01.salary)::text, ';'::text) IS NOT NULL)
|
|
-> Row Adapter
|
|
Output: depname, salary
|
|
-> CStore Scan on disable_vector_engine.vector_table_01
|
|
Output: depname, salary
|
|
(8 rows)
|
|
|
|
EXPLAIN (COSTS OFF, VERBOSE ON) SELECT DEPNAME FROM VECTOR_TABLE_01 GROUP BY DEPNAME HAVING STRING_AGG(SALARY,';') IS NOT NULL UNION ALL SELECT DEPNAME FROM VECTOR_TABLE_01 GROUP BY DEPNAME HAVING STRING_AGG(SALARY,';') IS NOT NULL;
|
|
QUERY PLAN
|
|
-------------------------------------------------------------------------------------------------------------------------------
|
|
Result
|
|
Output: disable_vector_engine.vector_table_01.depname
|
|
-> Append
|
|
-> HashAggregate
|
|
Output: disable_vector_engine.vector_table_01.depname
|
|
Group By Key: disable_vector_engine.vector_table_01.depname
|
|
Filter: (string_agg((disable_vector_engine.vector_table_01.salary)::text, ';'::text) IS NOT NULL)
|
|
-> Row Adapter
|
|
Output: disable_vector_engine.vector_table_01.depname, disable_vector_engine.vector_table_01.salary
|
|
-> CStore Scan on disable_vector_engine.vector_table_01
|
|
Output: disable_vector_engine.vector_table_01.depname, disable_vector_engine.vector_table_01.salary
|
|
-> HashAggregate
|
|
Output: disable_vector_engine.vector_table_01.depname
|
|
Group By Key: disable_vector_engine.vector_table_01.depname
|
|
Filter: (string_agg((disable_vector_engine.vector_table_01.salary)::text, ';'::text) IS NOT NULL)
|
|
-> Row Adapter
|
|
Output: disable_vector_engine.vector_table_01.depname, disable_vector_engine.vector_table_01.salary
|
|
-> CStore Scan on disable_vector_engine.vector_table_01
|
|
Output: disable_vector_engine.vector_table_01.depname, disable_vector_engine.vector_table_01.salary
|
|
(19 rows)
|
|
|
|
EXPLAIN (COSTS OFF, VERBOSE ON) SELECT LAST_VALUE(SALARY) OVER ( PARTITION BY DEPNAME ORDER BY SALARY, EMPNO) - 1 FROM VECTOR_TABLE_01;
|
|
QUERY PLAN
|
|
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
|
WindowAgg
|
|
Output: (last_value(salary) OVER (PARTITION BY depname ORDER BY salary USING = NULLS LAST, empno USING = NULLS LAST) - 1), salary, empno, depname
|
|
-> Sort
|
|
Output: salary, empno, depname
|
|
Sort Key: vector_table_01.depname, vector_table_01.salary, vector_table_01.empno
|
|
-> Row Adapter
|
|
Output: salary, empno, depname
|
|
-> CStore Scan on disable_vector_engine.vector_table_01
|
|
Output: salary, empno, depname
|
|
(9 rows)
|
|
|
|
EXPLAIN (COSTS OFF, VERBOSE ON) SELECT AVG(SALARY) OVER ( PARTITION BY DEPNAME ORDER BY SALARY, EMPNO) - 1 FROM VECTOR_TABLE_01;
|
|
QUERY PLAN
|
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Row Adapter
|
|
Output: ((avg(salary) OVER (PARTITION BY depname ORDER BY salary USING = NULLS LAST, empno USING = NULLS LAST) - 1::numeric)), salary, empno, depname
|
|
-> Vector WindowAgg
|
|
Output: (avg(salary) OVER (PARTITION BY depname ORDER BY salary USING = NULLS LAST, empno USING = NULLS LAST) - 1::numeric), salary, empno, depname
|
|
-> Vector Sort
|
|
Output: salary, empno, depname
|
|
Sort Key: vector_table_01.depname, vector_table_01.salary, vector_table_01.empno
|
|
-> CStore Scan on disable_vector_engine.vector_table_01
|
|
Output: salary, empno, depname
|
|
(9 rows)
|
|
|
|
-- string_agg, fallback
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.REGION
|
|
(
|
|
R_REGIONKEY INT NOT NULL
|
|
, R_NAME CHAR(25) NOT NULL
|
|
, R_COMMENT VARCHAR(152)
|
|
)
|
|
WITH (ORIENTATION = COLUMN);
|
|
EXPLAIN (COSTS OFF, VERBOSE ON)
|
|
SELECT
|
|
R_REGIONKEY,
|
|
SUBSTR(STRING_AGG(R_NAME , ';'),
|
|
0,
|
|
LENGTH(STRING_AGG(R_NAME , ';')) - 1) R_NAME,
|
|
SUBSTR(STRING_AGG(A.R_COMMENT , ';'),
|
|
0,
|
|
LENGTH(STRING_AGG(R_COMMENT , ';')) - 1) R_COMMENT
|
|
FROM (SELECT R_REGIONKEY,
|
|
REPLACE(R_NAME, CHR(13) || CHR(10),'') R_NAME,
|
|
R_COMMENT
|
|
FROM
|
|
(
|
|
SELECT R_REGIONKEY, R_NAME, R_COMMENT ,
|
|
ROW_NUMBER() OVER(PARTITION BY R_REGIONKEY ORDER BY R_REGIONKEY) RN
|
|
FROM (SELECT R_REGIONKEY, R_NAME, R_COMMENT
|
|
FROM REGION
|
|
GROUP BY R_REGIONKEY, R_NAME, R_COMMENT
|
|
)
|
|
)
|
|
WHERE RN < 7) A
|
|
GROUP BY R_REGIONKEY;
|
|
QUERY PLAN
|
|
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
GroupAggregate
|
|
Output: __unnamed_subquery__.r_regionkey, substr(string_agg(replace((__unnamed_subquery__.r_name)::text, '\r
|
|
'::text, NULL::text), ';'::text), 0, (length(string_agg(replace((__unnamed_subquery__.r_name)::text, '\r
|
|
'::text, NULL::text), ';'::text)) - 1)), substr(string_agg((__unnamed_subquery__.r_comment)::text, ';'::text), 0, (length(string_agg((__unnamed_subquery__.r_comment)::text, ';'::text)) - 1))
|
|
Group By Key: __unnamed_subquery__.r_regionkey
|
|
-> Subquery Scan on __unnamed_subquery__
|
|
Output: __unnamed_subquery__.r_regionkey, __unnamed_subquery__.r_name, __unnamed_subquery__.r_comment, __unnamed_subquery__.rn
|
|
Filter: (__unnamed_subquery__.rn < 7)
|
|
-> WindowAgg
|
|
Output: region.r_regionkey, region.r_name, region.r_comment, row_number() OVER (PARTITION BY region.r_regionkey)
|
|
-> Sort
|
|
Output: region.r_regionkey, region.r_name, region.r_comment
|
|
Sort Key: region.r_regionkey
|
|
-> HashAggregate
|
|
Output: region.r_regionkey, region.r_name, region.r_comment
|
|
Group By Key: region.r_regionkey, region.r_name, region.r_comment
|
|
-> Row Adapter
|
|
Output: region.r_regionkey, region.r_name, region.r_comment
|
|
-> CStore Scan on disable_vector_engine.region
|
|
Output: region.r_regionkey, region.r_name, region.r_comment
|
|
(20 rows)
|
|
|
|
-- Result is a leaf node
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_01(
|
|
W_NAME CHAR(10),
|
|
W_STREET_1 CHARACTER VARYING(20),
|
|
W_ZIP CHAR(9),
|
|
W_ID INTEGER, PARTIAL CLUSTER KEY(W_NAME))
|
|
WITH (ORIENTATION=COLUMN, MAX_BATCHROW= 30700, COMPRESSION = HIGH)
|
|
PARTITION BY RANGE (W_ID)
|
|
(
|
|
PARTITION FVT_DISTRIBUTE_QUERY_TABLES_01_P1 VALUES LESS THAN (6),
|
|
PARTITION FVT_DISTRIBUTE_QUERY_TABLES_01_P2 VALUES LESS THAN (8),
|
|
PARTITION FVT_DISTRIBUTE_QUERY_TABLES_01_P3 VALUES LESS THAN (MAXVALUE)
|
|
);
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_02(
|
|
C_ID VARCHAR,
|
|
C_STREET_1 VARCHAR(20),
|
|
C_CITY TEXT,
|
|
C_ZIP VARCHAR(9),
|
|
C_D_ID NUMERIC,
|
|
C_W_ID TEXT, PARTIAL CLUSTER KEY(C_ID,C_W_ID))
|
|
WITH (ORIENTATION=COLUMN, MAX_BATCHROW= 30700, COMPRESSION = HIGH)
|
|
;
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_03(
|
|
D_W_ID INTEGER,
|
|
D_NAME CHARACTER VARYING(10),
|
|
D_STREET_2 CHARACTER VARYING(20),
|
|
D_CITY CHARACTER VARYING(20),
|
|
D_ID INTEGER)
|
|
WITH (ORIENTATION=COLUMN, MAX_BATCHROW= 38700, COMPRESSION = YES)
|
|
;
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_04(
|
|
W_ID INTEGER,
|
|
W_NAME VARCHAR(20),
|
|
W_ZIP INTEGER, PARTIAL CLUSTER KEY(W_ID))
|
|
WITH (ORIENTATION=COLUMN)
|
|
;
|
|
SET ENABLE_HASHJOIN = OFF;
|
|
EXPLAIN (COSTS OFF)
|
|
SELECT TABLE_01.W_NAME,
|
|
TABLE_02.C_D_ID < 8 T2,
|
|
TABLE_02.C_CITY,
|
|
TABLE_03.D_W_ID,
|
|
TABLE_04.W_NAME
|
|
FROM DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_01 AS TABLE_01
|
|
FULL OUTER JOIN DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_02 AS TABLE_02
|
|
ON COALESCE(TABLE_01.W_ID, 1) = TABLE_02.C_W_ID
|
|
AND TABLE_02.C_ID NOT IN (10, 11, 12, 18, 39, 80, 88, 99, NULL)
|
|
INNER JOIN DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_03 AS TABLE_03
|
|
ON TABLE_01.W_ID = TABLE_03.D_W_ID
|
|
FULL OUTER JOIN DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_04 AS TABLE_04
|
|
ON TABLE_04.W_ID = TABLE_03.D_W_ID
|
|
WHERE COALESCE(TABLE_03.D_ID, 2) > 1
|
|
AND COALESCE(TABLE_03.D_W_ID, 3) < 9
|
|
ORDER BY TABLE_01.W_NAME,
|
|
T2,
|
|
TABLE_02.C_CITY,
|
|
TABLE_03.D_W_ID,
|
|
TABLE_04.W_NAME;
|
|
QUERY PLAN
|
|
------------------------------------------------------------------------------------------------------------------------
|
|
Row Adapter
|
|
-> Vector Sort
|
|
Sort Key: table_01.w_name, ((table_02.c_d_id < 8::numeric)), table_02.c_city, table_03.d_w_id, table_04.w_name
|
|
-> Vector Merge Full Join
|
|
Merge Cond: (table_03.d_w_id = table_04.w_id)
|
|
Filter: ((COALESCE(table_03.d_id, 2) > 1) AND (COALESCE(table_03.d_w_id, 3) < 9))
|
|
-> Vector Merge Join
|
|
Merge Cond: (table_03.d_w_id = table_01.w_id)
|
|
-> Vector Sort
|
|
Sort Key: table_03.d_w_id
|
|
-> CStore Scan on fvt_distribute_query_tables_03 table_03
|
|
-> Vector Sort
|
|
Sort Key: table_01.w_id
|
|
-> Vector Nest Loop Left Join
|
|
Join Filter: false
|
|
-> Vector Partition Iterator
|
|
Iterations: 3
|
|
-> Partitioned CStore Scan on fvt_distribute_query_tables_01 table_01
|
|
Selected Partitions: 1..3
|
|
-> Vector Adapter
|
|
-> Result
|
|
One-Time Filter: false
|
|
-> Vector Sort
|
|
Sort Key: table_04.w_id
|
|
-> CStore Scan on fvt_distribute_query_tables_04 table_04
|
|
(25 rows)
|
|
|
|
RESET ENABLE_HASHJOIN;
|
|
-- Subquery exists in fromlist of join tree
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.STORE
|
|
(
|
|
s_store_sk INTEGER not null,
|
|
s_store_id CHAR(16) not null,
|
|
s_rec_start_date DATE ,
|
|
s_rec_end_date DATE ,
|
|
s_closed_date_sk INTEGER ,
|
|
s_store_name VARCHAR(50) ,
|
|
s_number_employees INTEGER ,
|
|
s_floor_space INTEGER ,
|
|
s_hours CHAR(20) ,
|
|
s_manager VARCHAR(40) ,
|
|
s_market_id INTEGER ,
|
|
s_geography_class VARCHAR(100) ,
|
|
s_market_desc VARCHAR(100) ,
|
|
s_market_manager VARCHAR(40) ,
|
|
s_division_id INTEGER ,
|
|
s_division_name VARCHAR(50) ,
|
|
s_company_id INTEGER ,
|
|
s_company_name VARCHAR(50) ,
|
|
s_street_number VARCHAR(10) ,
|
|
s_street_name VARCHAR(60) ,
|
|
s_street_type CHAR(15) ,
|
|
s_suite_number CHAR(10) ,
|
|
s_city VARCHAR(60) ,
|
|
s_county VARCHAR(30) ,
|
|
s_state CHAR(2) ,
|
|
s_zip CHAR(10) ,
|
|
s_country VARCHAR(20) ,
|
|
s_gmt_offset DECIMAL(5,2) ,
|
|
s_tax_precentage DECIMAL(5,2)
|
|
)
|
|
WITH (ORIENTATION = COLUMN)
|
|
;
|
|
|
|
CREATE TABLE DISABLE_VECTOR_ENGINE.CUSTOMER
|
|
(
|
|
c_customer_sk INTEGER NOT NULL,
|
|
c_customer_id CHAR(16) NOT NULL,
|
|
c_current_cdemo_sk INTEGER ,
|
|
c_current_hdemo_sk INTEGER ,
|
|
c_current_addr_sk INTEGER ,
|
|
c_first_shipto_date_sk INTEGER ,
|
|
c_first_sales_date_sk INTEGER ,
|
|
c_salutation CHAR(10) ,
|
|
c_first_name CHAR(20) ,
|
|
c_last_name CHAR(30) ,
|
|
c_preferred_cust_flag CHAR(1) ,
|
|
c_birth_day INTEGER ,
|
|
c_birth_month INTEGER ,
|
|
c_birth_year INTEGER ,
|
|
c_birth_country VARCHAR(20) ,
|
|
c_login CHAR(13) ,
|
|
c_email_address CHAR(50) ,
|
|
c_last_review_date CHAR(10)
|
|
)
|
|
WITH (ORIENTATION = COLUMN)
|
|
;
|
|
EXPLAIN (COSTS OFF)
|
|
SELECT COUNT(8)
|
|
FROM (SELECT c_birth_day,
|
|
c_birth_month,
|
|
LPAD(LOWER(c_customer_id), 20, '-')
|
|
FROM customer
|
|
WHERE c_birth_day%2 = 0
|
|
AND ('1999-03-13', c_birth_day, c_customer_sk, 5,
|
|
COALESCE(c_birth_month, 9)) <= ANY
|
|
(SELECT s_rec_end_date,
|
|
s_market_id,
|
|
s_closed_date_sk,
|
|
TRUNC(ABS(s_gmt_offset)),
|
|
LEAD(s_store_sk) over a
|
|
FROM store window a AS(PARTITION BY s_rec_end_date, s_market_id ORDER BY s_rec_end_date, s_market_id, s_closed_date_sk, s_gmt_offset))
|
|
AND c_birth_country LIKE '%J%'
|
|
AND c_last_name LIKE '%a%'
|
|
GROUP BY 3, 2, 1
|
|
ORDER BY 1, 2, 3 DESC);
|
|
QUERY PLAN
|
|
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
Aggregate
|
|
-> Group
|
|
Group By Key: customer.c_birth_day, customer.c_birth_month, (lpad(lower((customer.c_customer_id)::text), 20, '-'::text))
|
|
-> Sort
|
|
Sort Key: customer.c_birth_day, customer.c_birth_month, (lpad(lower((customer.c_customer_id)::text), 20, '-'::text)) DESC
|
|
-> Nested Loop Semi Join
|
|
Join Filter: (ROW('Sat Mar 13 00:00:00 1999'::timestamp without time zone, customer.c_birth_day, customer.c_customer_sk, 5::numeric, COALESCE(customer.c_birth_month, 9)) <= ROW("ANY_subquery".s_rec_end_date, "ANY_subquery".s_market_id, "ANY_subquery".s_closed_date_sk, "ANY_subquery".trunc, "ANY_subquery".lead))
|
|
-> Row Adapter
|
|
-> CStore Scan on customer
|
|
Filter: (((c_birth_country)::text ~~ '%J%'::text) AND (c_last_name ~~ '%a%'::text) AND ((c_birth_day % 2) = 0))
|
|
-> Materialize
|
|
-> Subquery Scan on "ANY_subquery"
|
|
-> WindowAgg
|
|
-> Sort
|
|
Sort Key: store.s_rec_end_date, store.s_market_id, store.s_closed_date_sk, store.s_gmt_offset
|
|
-> Row Adapter
|
|
-> CStore Scan on store
|
|
(17 rows)
|
|
|
|
-- unsupported feature in ctelist
|
|
EXPLAIN (COSTS OFF)
|
|
INSERT INTO store(s_store_sk)
|
|
WITH v1 as(
|
|
SELECT c_customer_sk,
|
|
SUM(c_customer_sk) over
|
|
(PARTITION BY c_customer_sk, c_customer_id)
|
|
avg_customer_sk,
|
|
STDDEV_SAMP(c_customer_sk) stdev
|
|
FROM customer
|
|
GROUP BY c_customer_sk, c_customer_id),
|
|
v2 as(
|
|
SELECT v1.c_customer_sk FROM v1)
|
|
SELECT * FROM v2;
|
|
QUERY PLAN
|
|
------------------------------------------------------------------------------------------------------------------
|
|
Row Adapter
|
|
-> Vector Insert on store
|
|
-> Vector Adapter
|
|
-> Subquery Scan on "*SELECT*"
|
|
-> CTE Scan on v2
|
|
CTE v1
|
|
-> Row Adapter
|
|
-> Vector WindowAgg
|
|
-> Vector Sort
|
|
Sort Key: customer.c_customer_sk, customer.c_customer_id
|
|
-> Vector Hash Aggregate
|
|
Group By Key: customer.c_customer_sk, customer.c_customer_id
|
|
-> CStore Scan on customer
|
|
CTE v2
|
|
-> CTE Scan on v1
|
|
(15 rows)
|
|
|
|
explain (costs off)
|
|
INSERT INTO store(s_store_sk)
|
|
WITH v1 as(
|
|
SELECT c_customer_sk,
|
|
SUM(c_customer_sk) over
|
|
(PARTITION BY c_customer_sk, c_customer_id)
|
|
avg_customer_sk,
|
|
STDDEV_pop(c_customer_sk) stdev
|
|
FROM customer
|
|
GROUP BY c_customer_sk, c_customer_id),
|
|
v2 as(
|
|
SELECT v1.c_customer_sk FROM v1)
|
|
SELECT * FROM v2;
|
|
QUERY PLAN
|
|
------------------------------------------------------------------------------------------------------------
|
|
Row Adapter
|
|
-> Vector Insert on store
|
|
-> Vector Adapter
|
|
-> Subquery Scan on "*SELECT*"
|
|
-> CTE Scan on v2
|
|
CTE v1
|
|
-> WindowAgg
|
|
-> Sort
|
|
Sort Key: customer.c_customer_sk, customer.c_customer_id
|
|
-> HashAggregate
|
|
Group By Key: customer.c_customer_sk, customer.c_customer_id
|
|
-> Row Adapter
|
|
-> CStore Scan on customer
|
|
CTE v2
|
|
-> CTE Scan on v1
|
|
(15 rows)
|
|
|
|
----
|
|
--- Drop Tables
|
|
----
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.VECTOR_TABLE_01;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.VECTOR_TABLE_02;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.VECTOR_TABLE_03;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.ROW_TABLE_01;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.REGION;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_01;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_02;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_03;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.FVT_DISTRIBUTE_QUERY_TABLES_04;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.STORE;
|
|
DROP TABLE DISABLE_VECTOR_ENGINE.CUSTOMER;
|
|
DROP SCHEMA DISABLE_VECTOR_ENGINE CASCADE;
|
|
NOTICE: drop cascades to 3 other objects
|
|
DETAIL: drop cascades to table t1
|
|
drop cascades to table t2
|
|
drop cascades to table col_table
|