update some tests

pull/3900/head
Sait Talha Nisanci 2020-06-08 22:38:53 +03:00
parent 6ad708642e
commit 17388e2e91
6 changed files with 4412 additions and 152 deletions

View File

@ -15,7 +15,7 @@ SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int;
substring
---------------------------------------------------------------------
12
13
(1 row)
SET client_min_messages TO DEBUG;
@ -747,8 +747,8 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: (SELECT intermediate
DEBUG: Creating router plan
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test29 | {"f1": 29, "f2": 522, "f3": "test29"} | 1
9 | test9 | {"f1": 9, "f2": 162, "f3": "test9"} | 1
9 | test29 | {"f1": 29, "f2": 522, "f3": "test29"} | 1
9 | test19 | {"f1": 19, "f2": 342, "f3": "test19"} | 1
(3 rows)

View File

@ -15,7 +15,7 @@ SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int;
substring
---------------------------------------------------------------------
11
12
(1 row)
SET client_min_messages TO DEBUG;
@ -48,7 +48,19 @@ SELECT
FROM
cte_1
ORDER BY 2 DESC LIMIT 1;
ERROR: syntax error at or near "NOT"
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: generating subplan XXX_1 for CTE cte_1: SELECT key, value, other_value FROM cte_inline.test_table
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT key, value, other_value, (SELECT 1) FROM (SELECT intermediate_result.key, intermediate_result.value, intermediate_result.other_value FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer, value text, other_value jsonb)) cte_1 ORDER BY value DESC LIMIT 1
DEBUG: Creating router plan
DEBUG: Plan is router executable
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | {"f1": 99, "f2": 1782, "f3": "test99"} | 1
(1 row)
-- the cte can be inlined because the unsupported
-- part of the query (subquery in WHERE clause)
-- doesn't access the cte
@ -292,7 +304,9 @@ FROM
WHERE
key = 1;
DEBUG: CTE a is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Creating router plan
DEBUG: Plan is router executable
DETAIL: distribution column value: 1
count
---------------------------------------------------------------------
10
@ -306,7 +320,15 @@ FROM
a
WHERE
key = 1;
ERROR: syntax error at or near "NOT"
DEBUG: CTE a is going to be inlined via distributed planning
DEBUG: Creating router plan
DEBUG: Plan is router executable
DETAIL: distribution column value: 1
count
---------------------------------------------------------------------
10
(1 row)
-- using MATERIALIZED should cause inlining not to happen
WITH a AS MATERIALIZED (SELECT * FROM test_table)
SELECT
@ -315,7 +337,17 @@ FROM
a
WHERE
key = 1;
ERROR: syntax error at or near "MATERIALIZED"
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: generating subplan XXX_1 for CTE a: SELECT key, value, other_value FROM cte_inline.test_table
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM (SELECT intermediate_result.key, intermediate_result.value, intermediate_result.other_value FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer, value text, other_value jsonb)) a WHERE (key OPERATOR(pg_catalog.=) 1)
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
---------------------------------------------------------------------
10
(1 row)
-- EXPLAIN should show the difference between materialized an not materialized
EXPLAIN (COSTS OFF) WITH a AS (SELECT * FROM test_table)
SELECT
@ -325,19 +357,20 @@ FROM
WHERE
key = 1;
DEBUG: CTE a is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
QUERY PLAN
DEBUG: Creating router plan
DEBUG: Plan is router executable
DETAIL: distribution column value: 1
QUERY PLAN
---------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Aggregate
-> Seq Scan on test_table_1960000 test_table
Filter: (key = 1)
(9 rows)
Custom Scan (Citus Adaptive)
Task Count: 1
Tasks Shown: All
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Aggregate
-> Seq Scan on test_table_1960000 test_table
Filter: (key = 1)
(8 rows)
EXPLAIN (COSTS OFF) WITH a AS MATERIALIZED (SELECT * FROM test_table)
SELECT
@ -346,7 +379,31 @@ FROM
a
WHERE
key = 1;
ERROR: syntax error at or near "MATERIALIZED"
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: generating subplan XXX_1 for CTE a: SELECT key, value, other_value FROM cte_inline.test_table
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM (SELECT intermediate_result.key, intermediate_result.value, intermediate_result.other_value FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer, value text, other_value jsonb)) a WHERE (key OPERATOR(pg_catalog.=) 1)
DEBUG: Creating router plan
DEBUG: Plan is router executable
QUERY PLAN
---------------------------------------------------------------------
Custom Scan (Citus Adaptive)
-> Distributed Subplan XXX_1
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on test_table_1960000 test_table
Task Count: 1
Tasks Shown: All
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Aggregate
-> Function Scan on read_intermediate_result intermediate_result
Filter: (key = 1)
(15 rows)
-- citus should not inline the CTE because it is used multiple times
WITH cte_1 AS (SELECT * FROM test_table)
SELECT
@ -375,7 +432,25 @@ FROM
JOIN
cte_1 as second_entry
USING (key);
ERROR: syntax error at or near "NOT"
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: join prunable for intervals [-2147483648,-1073741825] and [-1073741824,-1]
DEBUG: join prunable for intervals [-2147483648,-1073741825] and [0,1073741823]
DEBUG: join prunable for intervals [-2147483648,-1073741825] and [1073741824,2147483647]
DEBUG: join prunable for intervals [-1073741824,-1] and [-2147483648,-1073741825]
DEBUG: join prunable for intervals [-1073741824,-1] and [0,1073741823]
DEBUG: join prunable for intervals [-1073741824,-1] and [1073741824,2147483647]
DEBUG: join prunable for intervals [0,1073741823] and [-2147483648,-1073741825]
DEBUG: join prunable for intervals [0,1073741823] and [-1073741824,-1]
DEBUG: join prunable for intervals [0,1073741823] and [1073741824,2147483647]
DEBUG: join prunable for intervals [1073741824,2147483647] and [-2147483648,-1073741825]
DEBUG: join prunable for intervals [1073741824,2147483647] and [-1073741824,-1]
DEBUG: join prunable for intervals [1073741824,2147483647] and [0,1073741823]
count
---------------------------------------------------------------------
1021
(1 row)
-- EXPLAIN should show the differences between MATERIALIZED and NOT MATERIALIZED
EXPLAIN (COSTS OFF) WITH cte_1 AS (SELECT * FROM test_table)
SELECT
@ -423,7 +498,36 @@ FROM
JOIN
cte_1 as second_entry
USING (key);
ERROR: syntax error at or near "NOT"
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: join prunable for intervals [-2147483648,-1073741825] and [-1073741824,-1]
DEBUG: join prunable for intervals [-2147483648,-1073741825] and [0,1073741823]
DEBUG: join prunable for intervals [-2147483648,-1073741825] and [1073741824,2147483647]
DEBUG: join prunable for intervals [-1073741824,-1] and [-2147483648,-1073741825]
DEBUG: join prunable for intervals [-1073741824,-1] and [0,1073741823]
DEBUG: join prunable for intervals [-1073741824,-1] and [1073741824,2147483647]
DEBUG: join prunable for intervals [0,1073741823] and [-2147483648,-1073741825]
DEBUG: join prunable for intervals [0,1073741823] and [-1073741824,-1]
DEBUG: join prunable for intervals [0,1073741823] and [1073741824,2147483647]
DEBUG: join prunable for intervals [1073741824,2147483647] and [-2147483648,-1073741825]
DEBUG: join prunable for intervals [1073741824,2147483647] and [-1073741824,-1]
DEBUG: join prunable for intervals [1073741824,2147483647] and [0,1073741823]
QUERY PLAN
---------------------------------------------------------------------
Aggregate
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Aggregate
-> Hash Join
Hash Cond: (test_table.key = test_table_1.key)
-> Seq Scan on test_table_1960000 test_table
-> Hash
-> Seq Scan on test_table_1960000 test_table_1
(12 rows)
-- ctes with volatile functions are not
-- inlined
WITH cte_1 AS (SELECT *, random() FROM test_table)
@ -448,7 +552,17 @@ SELECT
count(*)
FROM
cte_1;
ERROR: syntax error at or near "NOT"
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: generating subplan XXX_1 for CTE cte_1: SELECT key, value, other_value, random() AS random FROM cte_inline.test_table
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM (SELECT intermediate_result.key, intermediate_result.value, intermediate_result.other_value, intermediate_result.random FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer, value text, other_value jsonb, random double precision)) cte_1
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
---------------------------------------------------------------------
101
(1 row)
-- cte_1 should be able to inlined even if
-- it is used one level below
WITH cte_1 AS (SELECT * FROM test_table)
@ -504,11 +618,11 @@ SELECT count(*)
LEFT JOIN test_table u2 ON u2.key = bar.key) AS foo ON TRUE;
DEBUG: CTE bar is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: skipping recursive planning for the subquery since it contains references to outer queries
DEBUG: skipping recursive planning for the subquery since it contains references to outer queries
DEBUG: skipping recursive planning for the subquery since it contains references to outer queries
DEBUG: Router planner cannot handle multi-shard select queries
ERROR: CTEs that refer to other subqueries are not supported in multi-shard queries
count
---------------------------------------------------------------------
10331
(1 row)
-- inlined CTE contains a reference to outer query
-- should be fine (even if the recursive planning fails
-- to recursively plan the query)
@ -581,7 +695,9 @@ DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Creating router plan
DEBUG: Plan is router executable
DETAIL: distribution column value: 1
count | key
---------------------------------------------------------------------
(0 rows)
@ -695,17 +811,11 @@ FROM
cte LEFT JOIN test_table USING (key);
DEBUG: CTE cte is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: generating subplan XXX_1 for subquery SELECT key, value, other_value FROM cte_inline.test_table
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((SELECT intermediate_result.key, intermediate_result.value, intermediate_result.other_value FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer, value text, other_value jsonb)) cte LEFT JOIN cte_inline.test_table USING (key))
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: generating subplan XXX_1 for CTE cte: SELECT key, value, other_value FROM cte_inline.test_table
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((SELECT intermediate_result.key, intermediate_result.value, intermediate_result.other_value FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer, value text, other_value jsonb)) cte LEFT JOIN cte_inline.test_table USING (key))
DEBUG: Router planner cannot handle multi-shard select queries
ERROR: cannot pushdown the subquery
DETAIL: Complex subqueries and CTEs cannot be in the outer part of the outer join
count
---------------------------------------------------------------------
1021
(1 row)
-- the CTEs are very simple, so postgres
-- can pull-up the subqueries after inlining
-- the CTEs, and the query that we send to workers
@ -719,10 +829,18 @@ FROM
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: CTE cte_2 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: generating subplan XXX_1 for subquery SELECT key FROM cte_inline.test_table
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM ((SELECT test_table.key FROM cte_inline.test_table) cte_1 JOIN (SELECT intermediate_result.key FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer)) cte_2 USING (key))
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: join prunable for intervals [-2147483648,-1073741825] and [-1073741824,-1]
DEBUG: join prunable for intervals [-2147483648,-1073741825] and [0,1073741823]
DEBUG: join prunable for intervals [-2147483648,-1073741825] and [1073741824,2147483647]
DEBUG: join prunable for intervals [-1073741824,-1] and [-2147483648,-1073741825]
DEBUG: join prunable for intervals [-1073741824,-1] and [0,1073741823]
DEBUG: join prunable for intervals [-1073741824,-1] and [1073741824,2147483647]
DEBUG: join prunable for intervals [0,1073741823] and [-2147483648,-1073741825]
DEBUG: join prunable for intervals [0,1073741823] and [-1073741824,-1]
DEBUG: join prunable for intervals [0,1073741823] and [1073741824,2147483647]
DEBUG: join prunable for intervals [1073741824,2147483647] and [-2147483648,-1073741825]
DEBUG: join prunable for intervals [1073741824,2147483647] and [-1073741824,-1]
DEBUG: join prunable for intervals [1073741824,2147483647] and [0,1073741823]
count
---------------------------------------------------------------------
1021
@ -778,7 +896,12 @@ DEBUG: Creating router plan
-- we de still don't support it
WITH cte_1 AS NOT MATERIALIZED (SELECT * FROM test_table)
DELETE FROM test_table WHERE key NOT IN (SELECT key FROM cte_1);
ERROR: syntax error at or near "NOT"
DEBUG: complex joins are only supported when all distributed tables are co-located and joined on their distribution columns
DEBUG: generating subplan XXX_1 for CTE cte_1: SELECT key, value, other_value FROM cte_inline.test_table
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Plan XXX query after replacing subqueries and CTEs: DELETE FROM cte_inline.test_table WHERE (NOT (key OPERATOR(pg_catalog.=) ANY (SELECT cte_1.key FROM (SELECT intermediate_result.key, intermediate_result.value, intermediate_result.other_value FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer, value text, other_value jsonb)) cte_1)))
DEBUG: Creating router plan
DEBUG: Plan is router executable
-- we don't inline CTEs if they are modifying CTEs
WITH cte_1 AS (DELETE FROM test_table WHERE key % 3 = 1 RETURNING key)
SELECT * FROM cte_1 ORDER BY 1 DESC LIMIT 3;
@ -797,7 +920,18 @@ DEBUG: Creating router plan
-- NOT MATERIALIZED should not affect modifying CTEs
WITH cte_1 AS NOT MATERIALIZED (DELETE FROM test_table WHERE key % 3 = 0 RETURNING key)
SELECT count(*) FROM cte_1;
ERROR: syntax error at or near "NOT"
DEBUG: data-modifying statements are not supported in the WITH clauses of distributed queries
DEBUG: generating subplan XXX_1 for CTE cte_1: DELETE FROM cte_inline.test_table WHERE ((key OPERATOR(pg_catalog.%) 3) OPERATOR(pg_catalog.=) 0) RETURNING key
DEBUG: Creating router plan
DEBUG: Plan is router executable
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS count FROM (SELECT intermediate_result.key FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer)) cte_1
DEBUG: Creating router plan
DEBUG: Plan is router executable
count
---------------------------------------------------------------------
164
(1 row)
-- cte with column aliases
SELECT * FROM test_table,
(WITH cte_1 (x,y) AS (SELECT * FROM test_table),
@ -813,13 +947,13 @@ DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT test_table.key, test_table.value, test_table.other_value, bar.z, bar.y, bar.key, bar.t, bar.m, bar.cte_2_key FROM cte_inline.test_table, (SELECT cte_2.z, cte_2.y, cte_2.key, cte_3.t, cte_3.m, cte_3.cte_2_key FROM (SELECT intermediate_result.value AS z, intermediate_result.other_value AS y, intermediate_result.key FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(value text, other_value jsonb, key integer)) cte_2, (SELECT cte_2_1.z AS t, cte_2_1.y AS m, cte_2_1.key AS cte_2_key FROM (SELECT intermediate_result.value AS z, intermediate_result.other_value AS y, intermediate_result.key FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(value text, other_value jsonb, key integer)) cte_2_1) cte_3) bar ORDER BY test_table.value, test_table.other_value, bar.z, bar.y, bar.t, bar.m, bar.cte_2_key LIMIT 5
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: push down of limit count: 5
key | value | other_value | z | y | key | t | m | cte_2_key
key | value | other_value | z | y | key | t | m | cte_2_key
---------------------------------------------------------------------
0 | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | 0 | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | 0
0 | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | 0 | test0 | | 0
0 | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | 0 | test0 | | 0
0 | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | 0 | test0 | | 0
0 | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | test0 | {"f1": 0, "f2": 0, "f3": "test0"} | 0 | test10 | {"f1": 10, "f2": 180, "f3": "test10"} | 0
2 | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | 2 | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | 2
2 | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | 2 | test12 | | 2
2 | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | 2 | test12 | | 2
2 | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | 2 | test12 | | 2
2 | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | test12 | {"f1": 12, "f2": 216, "f3": "test12"} | 2 | test15 | {"f1": 15, "f2": 270, "f3": "test15"} | 5
(5 rows)
-- cte used in HAVING subquery just works fine
@ -843,12 +977,10 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT key, count(*)
DEBUG: Router planner cannot handle multi-shard select queries
key | count
---------------------------------------------------------------------
0 | 44
9 | 40
8 | 40
6 | 40
5 | 40
(5 rows)
2 | 40
(3 rows)
-- cte used in ORDER BY just works fine
-- even if it is inlined
@ -869,9 +1001,9 @@ DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: push down of limit count: 3
key
---------------------------------------------------------------------
9
9
9
8
8
8
(3 rows)
PREPARE inlined_cte_without_params AS
@ -904,7 +1036,7 @@ DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: push down of limit count: 3
count
---------------------------------------------------------------------
44
40
40
40
(3 rows)
@ -912,7 +1044,7 @@ DEBUG: push down of limit count: 3
EXECUTE inlined_cte_without_params;
count
---------------------------------------------------------------------
44
40
40
40
(3 rows)
@ -920,7 +1052,7 @@ EXECUTE inlined_cte_without_params;
EXECUTE inlined_cte_without_params;
count
---------------------------------------------------------------------
44
40
40
40
(3 rows)
@ -928,7 +1060,7 @@ EXECUTE inlined_cte_without_params;
EXECUTE inlined_cte_without_params;
count
---------------------------------------------------------------------
44
40
40
40
(3 rows)
@ -936,7 +1068,7 @@ EXECUTE inlined_cte_without_params;
EXECUTE inlined_cte_without_params;
count
---------------------------------------------------------------------
44
40
40
40
(3 rows)
@ -944,7 +1076,7 @@ EXECUTE inlined_cte_without_params;
EXECUTE inlined_cte_without_params;
count
---------------------------------------------------------------------
44
40
40
40
(3 rows)
@ -959,49 +1091,49 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT key, value, o
DEBUG: Creating router plan
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_without_params;
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_without_params;
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_without_params;
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_without_params;
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_without_params;
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE inlined_cte_has_parameter_on_non_dist_key('test1');
@ -1027,8 +1159,7 @@ DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: push down of limit count: 3
count
---------------------------------------------------------------------
4
(1 row)
(0 rows)
EXECUTE inlined_cte_has_parameter_on_non_dist_key('test4');
DEBUG: CTE cte_1 is going to be inlined via distributed planning
@ -1055,8 +1186,7 @@ DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: push down of limit count: 3
count
---------------------------------------------------------------------
4
(1 row)
(0 rows)
EXECUTE inlined_cte_has_parameter_on_dist_key(1);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
@ -1077,8 +1207,7 @@ DEBUG: push down of limit count: 3
---------------------------------------------------------------------
40
40
40
(3 rows)
(2 rows)
EXECUTE inlined_cte_has_parameter_on_dist_key(3);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
@ -1088,8 +1217,7 @@ DEBUG: push down of limit count: 3
---------------------------------------------------------------------
40
40
40
(3 rows)
(2 rows)
EXECUTE inlined_cte_has_parameter_on_dist_key(4);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
@ -1099,8 +1227,7 @@ DEBUG: push down of limit count: 3
---------------------------------------------------------------------
40
40
40
(3 rows)
(2 rows)
EXECUTE inlined_cte_has_parameter_on_dist_key(5);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
@ -1109,9 +1236,7 @@ DEBUG: push down of limit count: 3
count
---------------------------------------------------------------------
40
40
40
(3 rows)
(1 row)
EXECUTE inlined_cte_has_parameter_on_dist_key(6);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
@ -1122,8 +1247,7 @@ DEBUG: push down of limit count: 3
count
---------------------------------------------------------------------
40
40
(2 rows)
(1 row)
EXECUTE non_inlined_cte_has_parameter_on_dist_key(1);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
@ -1135,9 +1259,9 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT key, value, o
DEBUG: Creating router plan
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_has_parameter_on_dist_key(2);
@ -1150,9 +1274,9 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT key, value, o
DEBUG: Creating router plan
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_has_parameter_on_dist_key(3);
@ -1165,9 +1289,9 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT key, value, o
DEBUG: Creating router plan
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_has_parameter_on_dist_key(4);
@ -1180,9 +1304,9 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT key, value, o
DEBUG: Creating router plan
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_has_parameter_on_dist_key(5);
@ -1195,9 +1319,9 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT key, value, o
DEBUG: Creating router plan
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE non_inlined_cte_has_parameter_on_dist_key(6);
@ -1212,49 +1336,49 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT key, value, o
DEBUG: Creating router plan
key | value | other_value | ?column?
---------------------------------------------------------------------
9 | test99 | | 1
9 | test99 | | 1
9 | test99 | | 1
8 | test98 | | 1
8 | test98 | | 1
8 | test98 | | 1
(3 rows)
EXECUTE retry_planning(1);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
json_object_agg
json_object_agg
---------------------------------------------------------------------
{ "2" : "test12", "2" : "test2", "2" : "test22", "2" : "test32", "2" : "test42", "2" : "test52", "2" : "test62", "2" : "test72", "2" : "test82", "2" : "test92", "3" : "test13", "3" : "test23", "3" : "test3", "3" : "test33", "3" : "test43", "3" : "test53", "3" : "test63", "3" : "test73", "3" : "test83", "3" : "test93", "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "6" : "test16", "6" : "test26", "6" : "test36", "6" : "test46", "6" : "test56", "6" : "test6", "6" : "test66", "6" : "test76", "6" : "test86", "6" : "test96", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98", "9" : "test19", "9" : "test29", "9" : "test39", "9" : "test49", "9" : "test59", "9" : "test69", "9" : "test79", "9" : "test89", "9" : "test9", "9" : "test99" }
{ "2" : "test12", "2" : "test2", "2" : "test22", "2" : "test32", "2" : "test42", "2" : "test52", "2" : "test62", "2" : "test72", "2" : "test82", "2" : "test92", "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98" }
(1 row)
EXECUTE retry_planning(2);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
json_object_agg
json_object_agg
---------------------------------------------------------------------
{ "3" : "test13", "3" : "test23", "3" : "test3", "3" : "test33", "3" : "test43", "3" : "test53", "3" : "test63", "3" : "test73", "3" : "test83", "3" : "test93", "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "6" : "test16", "6" : "test26", "6" : "test36", "6" : "test46", "6" : "test56", "6" : "test6", "6" : "test66", "6" : "test76", "6" : "test86", "6" : "test96", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98", "9" : "test19", "9" : "test29", "9" : "test39", "9" : "test49", "9" : "test59", "9" : "test69", "9" : "test79", "9" : "test89", "9" : "test9", "9" : "test99" }
{ "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98" }
(1 row)
EXECUTE retry_planning(3);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
json_object_agg
json_object_agg
---------------------------------------------------------------------
{ "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "6" : "test16", "6" : "test26", "6" : "test36", "6" : "test46", "6" : "test56", "6" : "test6", "6" : "test66", "6" : "test76", "6" : "test86", "6" : "test96", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98", "9" : "test19", "9" : "test29", "9" : "test39", "9" : "test49", "9" : "test59", "9" : "test69", "9" : "test79", "9" : "test89", "9" : "test9", "9" : "test99" }
{ "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98" }
(1 row)
EXECUTE retry_planning(4);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
json_object_agg
json_object_agg
---------------------------------------------------------------------
{ "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "6" : "test16", "6" : "test26", "6" : "test36", "6" : "test46", "6" : "test56", "6" : "test6", "6" : "test66", "6" : "test76", "6" : "test86", "6" : "test96", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98", "9" : "test19", "9" : "test29", "9" : "test39", "9" : "test49", "9" : "test59", "9" : "test69", "9" : "test79", "9" : "test89", "9" : "test9", "9" : "test99" }
{ "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98" }
(1 row)
EXECUTE retry_planning(5);
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
json_object_agg
json_object_agg
---------------------------------------------------------------------
{ "6" : "test16", "6" : "test26", "6" : "test36", "6" : "test46", "6" : "test56", "6" : "test6", "6" : "test66", "6" : "test76", "6" : "test86", "6" : "test96", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98", "9" : "test19", "9" : "test29", "9" : "test39", "9" : "test49", "9" : "test59", "9" : "test69", "9" : "test79", "9" : "test89", "9" : "test9", "9" : "test99" }
{ "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98" }
(1 row)
EXECUTE retry_planning(6);
@ -1262,9 +1386,9 @@ DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
json_object_agg
json_object_agg
---------------------------------------------------------------------
{ "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98", "9" : "test19", "9" : "test29", "9" : "test39", "9" : "test49", "9" : "test59", "9" : "test69", "9" : "test79", "9" : "test89", "9" : "test9", "9" : "test99" }
{ "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98" }
(1 row)
-- this test can only work if the CTE is recursively
@ -1286,7 +1410,7 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS c
DEBUG: Creating router plan
count
---------------------------------------------------------------------
11536
4800
(1 row)
-- this becomes a non-colocated subquery join
@ -1304,7 +1428,7 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT count(*) AS c
DEBUG: Router planner cannot handle multi-shard select queries
count
---------------------------------------------------------------------
1136
480
(1 row)
-- cte a has to be recursively planned because of OFFSET 0
@ -1328,7 +1452,7 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT min(a.key) AS
DEBUG: Creating router plan
min
---------------------------------------------------------------------
0
2
(1 row)
-- after both CTEs are inlined, this becomes non-colocated subquery join
@ -1343,11 +1467,11 @@ DEBUG: generating subplan XXX_1 for subquery SELECT key, value, other_value FRO
DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT cte_1.key, cte_1.value, cte_1.other_value, cte_2.key, cte_2.value, cte_2.other_value FROM ((SELECT test_table.key, test_table.value, test_table.other_value FROM cte_inline.test_table) cte_1 JOIN (SELECT intermediate_result.key, intermediate_result.value, intermediate_result.other_value FROM read_intermediate_result('XXX_1'::text, 'binary'::citus_copy_format) intermediate_result(key integer, value text, other_value jsonb)) cte_2 ON ((cte_1.value OPERATOR(pg_catalog.>) cte_2.value))) ORDER BY cte_1.key, cte_1.value, cte_1.other_value, cte_2.key, cte_2.value, cte_2.other_value DESC LIMIT 3
DEBUG: Router planner cannot handle multi-shard select queries
DEBUG: push down of limit count: 3
key | value | other_value | key | value | other_value
key | value | other_value | key | value | other_value
---------------------------------------------------------------------
0 | test10 | {"f1": 10, "f2": 180, "f3": "test10"} | 0 | test0 |
0 | test10 | {"f1": 10, "f2": 180, "f3": "test10"} | 0 | test0 |
0 | test10 | {"f1": 10, "f2": 180, "f3": "test10"} | 0 | test0 |
2 | test2 | {"f1": 2, "f2": 36, "f3": "test2"} | 2 | test12 |
2 | test2 | {"f1": 2, "f2": 36, "f3": "test2"} | 2 | test12 |
2 | test2 | {"f1": 2, "f2": 36, "f3": "test2"} | 2 | test12 |
(3 rows)
-- full join is only supported when both sides are
@ -1371,9 +1495,9 @@ DEBUG: Plan XXX query after replacing subqueries and CTEs: SELECT value FROM ((
DEBUG: Creating router plan
value
---------------------------------------------------------------------
test99
test99
test99
test98
test98
test98
(3 rows)
-- an unsupported agg. for multi-shard queries
@ -1382,9 +1506,9 @@ WITH cte_1 AS (SELECT * FROM test_table WHERE key > 1)
SELECT json_object_agg(DISTINCT key, value) FROM cte_1;
DEBUG: CTE cte_1 is going to be inlined via distributed planning
DEBUG: Router planner cannot handle multi-shard select queries
json_object_agg
json_object_agg
---------------------------------------------------------------------
{ "2" : "test12", "2" : "test2", "2" : "test22", "2" : "test32", "2" : "test42", "2" : "test52", "2" : "test62", "2" : "test72", "2" : "test82", "2" : "test92", "3" : "test13", "3" : "test23", "3" : "test3", "3" : "test33", "3" : "test43", "3" : "test53", "3" : "test63", "3" : "test73", "3" : "test83", "3" : "test93", "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "6" : "test16", "6" : "test26", "6" : "test36", "6" : "test46", "6" : "test56", "6" : "test6", "6" : "test66", "6" : "test76", "6" : "test86", "6" : "test96", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98", "9" : "test19", "9" : "test29", "9" : "test39", "9" : "test49", "9" : "test59", "9" : "test69", "9" : "test79", "9" : "test89", "9" : "test9", "9" : "test99" }
{ "2" : "test12", "2" : "test2", "2" : "test22", "2" : "test32", "2" : "test42", "2" : "test52", "2" : "test62", "2" : "test72", "2" : "test82", "2" : "test92", "5" : "test15", "5" : "test25", "5" : "test35", "5" : "test45", "5" : "test5", "5" : "test55", "5" : "test65", "5" : "test75", "5" : "test85", "5" : "test95", "8" : "test18", "8" : "test28", "8" : "test38", "8" : "test48", "8" : "test58", "8" : "test68", "8" : "test78", "8" : "test8", "8" : "test88", "8" : "test98" }
(1 row)
-- both cte_1 and cte_2 are going to be inlined.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -946,7 +946,7 @@ EXPLAIN (COSTS FALSE)
GROUP BY l_orderkey
ORDER BY 2
LIMIT 15;
QUERY PLAN
QUERY PLAN
---------------------------------------------------------------------
Limit
-> Sort
@ -958,12 +958,10 @@ EXPLAIN (COSTS FALSE)
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> GroupAggregate
-> HashAggregate
Group Key: l_orderkey
-> Sort
Sort Key: l_orderkey
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
(15 rows)
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
(13 rows)
-- check the plan if the hash aggreate is disabled.
SET enable_hashagg TO off;
@ -973,7 +971,7 @@ EXPLAIN (COSTS FALSE)
GROUP BY l_orderkey
ORDER BY 2
LIMIT 15;
QUERY PLAN
QUERY PLAN
---------------------------------------------------------------------
Limit
-> Unique
@ -984,12 +982,10 @@ EXPLAIN (COSTS FALSE)
Tasks Shown: One of 4
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> GroupAggregate
-> HashAggregate
Group Key: l_orderkey
-> Sort
Sort Key: l_orderkey
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
(14 rows)
-> Seq Scan on lineitem_hash_part_360041 lineitem_hash_part
(12 rows)
SET enable_hashagg TO on;
-- distinct on non-partition column with aggregate

File diff suppressed because it is too large Load Diff