Force CTE materialization in pg12

pull/2871/head
Philip Dubé 2019-08-07 18:15:51 +00:00
parent 667c67891e
commit 871dabdc63
15 changed files with 100 additions and 86 deletions

View File

@ -89,8 +89,8 @@ UNION
ERROR: the intermediate result size exceeds citus.max_intermediate_result_size (currently 0 kB) ERROR: the intermediate result size exceeds citus.max_intermediate_result_size (currently 0 kB)
DETAIL: Citus restricts the size of intermediate results of complex subqueries and CTEs to avoid accidentally pulling large result sets into once place. DETAIL: Citus restricts the size of intermediate results of complex subqueries and CTEs to avoid accidentally pulling large result sets into once place.
HINT: To run the current query, set citus.max_intermediate_result_size to a higher value or -1 to disable. HINT: To run the current query, set citus.max_intermediate_result_size to a higher value or -1 to disable.
-- this should fail since the cte-subplan exceeds the limit even if the -- this fails since cte-subplan exceeds limit even if cte2 and cte3 don't
-- cte2 and cte3 does not -- WHERE EXISTS forces materialization in pg12
SET citus.max_intermediate_result_size TO 4; SET citus.max_intermediate_result_size TO 4;
WITH cte AS ( WITH cte AS (
WITH cte2 AS ( WITH cte2 AS (
@ -100,8 +100,9 @@ WITH cte AS (
SELECT * FROM events_table SELECT * FROM events_table
) )
SELECT * FROM cte2, cte3 WHERE cte2.user_id = cte3.user_id AND cte2.user_id = 1 SELECT * FROM cte2, cte3 WHERE cte2.user_id = cte3.user_id AND cte2.user_id = 1
AND EXISTS (select * from cte2, cte3)
) )
SELECT * FROM cte; SELECT * FROM cte WHERE EXISTS (select * from cte);
ERROR: the intermediate result size exceeds citus.max_intermediate_result_size (currently 4 kB) ERROR: the intermediate result size exceeds citus.max_intermediate_result_size (currently 4 kB)
DETAIL: Citus restricts the size of intermediate results of complex subqueries and CTEs to avoid accidentally pulling large result sets into once place. DETAIL: Citus restricts the size of intermediate results of complex subqueries and CTEs to avoid accidentally pulling large result sets into once place.
HINT: To run the current query, set citus.max_intermediate_result_size to a higher value or -1 to disable. HINT: To run the current query, set citus.max_intermediate_result_size to a higher value or -1 to disable.

View File

@ -46,7 +46,7 @@ Sort
Sort Key: COALESCE((pg_catalog.sum((COALESCE((pg_catalog.sum(remote_scan.count_quantity))::bigint, '0'::bigint))))::bigint, '0'::bigint), remote_scan.l_quantity Sort Key: COALESCE((pg_catalog.sum((COALESCE((pg_catalog.sum(remote_scan.count_quantity))::bigint, '0'::bigint))))::bigint, '0'::bigint), remote_scan.l_quantity
-> HashAggregate -> HashAggregate
Group Key: remote_scan.l_quantity Group Key: remote_scan.l_quantity
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: One of 2 Tasks Shown: One of 2
-> Task -> Task
@ -65,7 +65,7 @@ Sort
Group Key: remote_scan.l_quantity Group Key: remote_scan.l_quantity
-> Sort -> Sort
Sort Key: remote_scan.l_quantity Sort Key: remote_scan.l_quantity
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: One of 2 Tasks Shown: One of 2
-> Task -> Task
@ -96,7 +96,7 @@ EXPLAIN (COSTS FALSE, FORMAT JSON)
{ {
"Node Type": "Custom Scan", "Node Type": "Custom Scan",
"Parent Relationship": "Outer", "Parent Relationship": "Outer",
"Custom Plan Provider": "Citus Real-Time", "Custom Plan Provider": "Citus Adaptive",
"Parallel Aware": false, "Parallel Aware": false,
"Distributed Query": { "Distributed Query": {
"Job": { "Job": {
@ -171,7 +171,7 @@ EXPLAIN (COSTS FALSE, FORMAT XML)
<Plan> <Plan>
<Node-Type>Custom Scan</Node-Type> <Node-Type>Custom Scan</Node-Type>
<Parent-Relationship>Outer</Parent-Relationship> <Parent-Relationship>Outer</Parent-Relationship>
<Custom-Plan-Provider>Citus Real-Time</Custom-Plan-Provider> <Custom-Plan-Provider>Citus Adaptive</Custom-Plan-Provider>
<Parallel-Aware>false</Parallel-Aware> <Parallel-Aware>false</Parallel-Aware>
<Distributed-Query> <Distributed-Query>
<Job> <Job>
@ -241,7 +241,7 @@ EXPLAIN (COSTS FALSE, FORMAT YAML)
Plans: Plans:
- Node Type: "Custom Scan" - Node Type: "Custom Scan"
Parent Relationship: "Outer" Parent Relationship: "Outer"
Custom Plan Provider: "Citus Real-Time" Custom Plan Provider: "Citus Adaptive"
Parallel Aware: false Parallel Aware: false
Distributed Query: Distributed Query:
Job: Job:
@ -272,7 +272,7 @@ Sort
Sort Key: COALESCE((pg_catalog.sum((COALESCE((pg_catalog.sum(remote_scan.count_quantity))::bigint, '0'::bigint))))::bigint, '0'::bigint), remote_scan.l_quantity Sort Key: COALESCE((pg_catalog.sum((COALESCE((pg_catalog.sum(remote_scan.count_quantity))::bigint, '0'::bigint))))::bigint, '0'::bigint), remote_scan.l_quantity
-> HashAggregate -> HashAggregate
Group Key: remote_scan.l_quantity Group Key: remote_scan.l_quantity
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: One of 2 Tasks Shown: One of 2
-> Task -> Task
@ -285,7 +285,7 @@ EXPLAIN (COSTS FALSE, VERBOSE TRUE)
SELECT sum(l_quantity) / avg(l_quantity) FROM lineitem; SELECT sum(l_quantity) / avg(l_quantity) FROM lineitem;
Aggregate Aggregate
Output: (sum(remote_scan."?column?") / (sum(remote_scan."?column?_1") / pg_catalog.sum(remote_scan."?column?_2"))) Output: (sum(remote_scan."?column?") / (sum(remote_scan."?column?_1") / pg_catalog.sum(remote_scan."?column?_2")))
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Output: remote_scan."?column?", remote_scan."?column?_1", remote_scan."?column?_2" Output: remote_scan."?column?", remote_scan."?column?_1", remote_scan."?column?_2"
Task Count: 2 Task Count: 2
Tasks Shown: One of 2 Tasks Shown: One of 2
@ -303,7 +303,7 @@ EXPLAIN (COSTS FALSE)
Limit Limit
-> Sort -> Sort
Sort Key: remote_scan.l_quantity Sort Key: remote_scan.l_quantity
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: One of 2 Tasks Shown: One of 2
-> Task -> Task
@ -320,7 +320,7 @@ Limit
-- Test insert -- Test insert
EXPLAIN (COSTS FALSE) EXPLAIN (COSTS FALSE)
INSERT INTO lineitem VALUES (1,0), (2, 0), (3, 0), (4, 0); INSERT INTO lineitem VALUES (1,0), (2, 0), (3, 0), (4, 0);
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 1 Task Count: 1
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -332,7 +332,7 @@ EXPLAIN (COSTS FALSE)
UPDATE lineitem UPDATE lineitem
SET l_suppkey = 12 SET l_suppkey = 12
WHERE l_orderkey = 1 AND l_partkey = 0; WHERE l_orderkey = 1 AND l_partkey = 0;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 1 Task Count: 1
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -345,7 +345,7 @@ Custom Scan (Citus Router)
EXPLAIN (COSTS FALSE) EXPLAIN (COSTS FALSE)
DELETE FROM lineitem DELETE FROM lineitem
WHERE l_orderkey = 1 AND l_partkey = 0; WHERE l_orderkey = 1 AND l_partkey = 0;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 1 Task Count: 1
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -359,20 +359,20 @@ EXPLAIN (COSTS FALSE)
UPDATE lineitem UPDATE lineitem
SET l_suppkey = 12 SET l_suppkey = 12
WHERE l_orderkey = 1 AND l_orderkey = 0; WHERE l_orderkey = 1 AND l_orderkey = 0;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 0 Task Count: 0
Tasks Shown: All Tasks Shown: All
-- Test zero-shard delete -- Test zero-shard delete
EXPLAIN (COSTS FALSE) EXPLAIN (COSTS FALSE)
DELETE FROM lineitem DELETE FROM lineitem
WHERE l_orderkey = 1 AND l_orderkey = 0; WHERE l_orderkey = 1 AND l_orderkey = 0;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 0 Task Count: 0
Tasks Shown: All Tasks Shown: All
-- Test single-shard SELECT -- Test single-shard SELECT
EXPLAIN (COSTS FALSE) EXPLAIN (COSTS FALSE)
SELECT l_quantity FROM lineitem WHERE l_orderkey = 5; SELECT l_quantity FROM lineitem WHERE l_orderkey = 5;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 1 Task Count: 1
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -389,7 +389,7 @@ t
EXPLAIN (COSTS FALSE) EXPLAIN (COSTS FALSE)
CREATE TABLE explain_result AS CREATE TABLE explain_result AS
SELECT * FROM lineitem; SELECT * FROM lineitem;
Custom Scan (Citus Real-Time) Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: One of 2 Tasks Shown: One of 2
-> Task -> Task
@ -402,7 +402,7 @@ EXPLAIN (COSTS FALSE, VERBOSE TRUE)
Aggregate Aggregate
Output: (sum(remote_scan."?column?") / (sum(remote_scan."?column?_1") / pg_catalog.sum(remote_scan."?column?_2"))) Output: (sum(remote_scan."?column?") / (sum(remote_scan."?column?_1") / pg_catalog.sum(remote_scan."?column?_2")))
Filter: (sum(remote_scan.worker_column_4) > '100'::numeric) Filter: (sum(remote_scan.worker_column_4) > '100'::numeric)
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Output: remote_scan."?column?", remote_scan."?column?_1", remote_scan."?column?_2", remote_scan.worker_column_4 Output: remote_scan."?column?", remote_scan."?column?_1", remote_scan."?column?_2", remote_scan.worker_column_4
Task Count: 2 Task Count: 2
Tasks Shown: One of 2 Tasks Shown: One of 2
@ -421,7 +421,7 @@ HashAggregate
Output: remote_scan.l_quantity Output: remote_scan.l_quantity
Group Key: remote_scan.l_quantity Group Key: remote_scan.l_quantity
Filter: ((remote_scan.worker_column_2)::double precision > ('100'::double precision * random())) Filter: ((remote_scan.worker_column_2)::double precision > ('100'::double precision * random()))
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Output: remote_scan.l_quantity, remote_scan.worker_column_2 Output: remote_scan.l_quantity, remote_scan.worker_column_2
Task Count: 2 Task Count: 2
Tasks Shown: One of 2 Tasks Shown: One of 2
@ -459,7 +459,7 @@ FROM
tenant_id, tenant_id,
user_id) AS subquery; user_id) AS subquery;
Aggregate Aggregate
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 4 Task Count: 4
Tasks Shown: One of 4 Tasks Shown: One of 4
-> Task -> Task
@ -541,7 +541,7 @@ GROUP BY
hasdone; hasdone;
HashAggregate HashAggregate
Group Key: remote_scan.hasdone Group Key: remote_scan.hasdone
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 4 Task Count: 4
Tasks Shown: One of 4 Tasks Shown: One of 4
-> Task -> Task
@ -709,7 +709,7 @@ LIMIT
Limit Limit
-> Sort -> Sort
Sort Key: remote_scan.user_lastseen DESC Sort Key: remote_scan.user_lastseen DESC
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 4 Task Count: 4
Tasks Shown: One of 4 Tasks Shown: One of 4
-> Task -> Task
@ -738,7 +738,7 @@ SET citus.explain_all_tasks TO on;
EXPLAIN (COSTS FALSE) EXPLAIN (COSTS FALSE)
SELECT avg(l_linenumber) FROM lineitem WHERE l_orderkey > 9030; SELECT avg(l_linenumber) FROM lineitem WHERE l_orderkey > 9030;
Aggregate Aggregate
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 1 Task Count: 1
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -757,7 +757,7 @@ t
EXPLAIN (COSTS FALSE) EXPLAIN (COSTS FALSE)
UPDATE lineitem_hash_part UPDATE lineitem_hash_part
SET l_suppkey = 12; SET l_suppkey = 12;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 4 Task Count: 4
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -781,7 +781,7 @@ EXPLAIN (COSTS FALSE)
UPDATE lineitem_hash_part UPDATE lineitem_hash_part
SET l_suppkey = 12 SET l_suppkey = 12
WHERE l_orderkey = 1 OR l_orderkey = 3; WHERE l_orderkey = 1 OR l_orderkey = 3;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -797,7 +797,7 @@ Custom Scan (Citus Router)
-- Test multi shard delete -- Test multi shard delete
EXPLAIN (COSTS FALSE) EXPLAIN (COSTS FALSE)
DELETE FROM lineitem_hash_part; DELETE FROM lineitem_hash_part;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 4 Task Count: 4
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -823,7 +823,7 @@ EXPLAIN (COSTS FALSE)
SET l_suppkey = 12 SET l_suppkey = 12
FROM orders_hash_part FROM orders_hash_part
WHERE orders_hash_part.o_orderkey = lineitem_hash_part.l_orderkey; WHERE orders_hash_part.o_orderkey = lineitem_hash_part.l_orderkey;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 4 Task Count: 4
Tasks Shown: One of 4 Tasks Shown: One of 4
-> Task -> Task
@ -839,7 +839,7 @@ EXPLAIN (COSTS FALSE)
DELETE FROM lineitem_hash_part DELETE FROM lineitem_hash_part
USING orders_hash_part USING orders_hash_part
WHERE orders_hash_part.o_orderkey = lineitem_hash_part.l_orderkey; WHERE orders_hash_part.o_orderkey = lineitem_hash_part.l_orderkey;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 4 Task Count: 4
Tasks Shown: One of 4 Tasks Shown: One of 4
-> Task -> Task
@ -1055,7 +1055,7 @@ Aggregate
RESET citus.task_executor_type; RESET citus.task_executor_type;
PREPARE router_executor_query AS SELECT l_quantity FROM lineitem WHERE l_orderkey = 5; PREPARE router_executor_query AS SELECT l_quantity FROM lineitem WHERE l_orderkey = 5;
EXPLAIN EXECUTE router_executor_query; EXPLAIN EXECUTE router_executor_query;
Custom Scan (Citus Router) (cost=0.00..0.00 rows=0 width=0) Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0)
Task Count: 1 Task Count: 1
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -1066,7 +1066,7 @@ PREPARE real_time_executor_query AS
SELECT avg(l_linenumber) FROM lineitem WHERE l_orderkey > 9030; SELECT avg(l_linenumber) FROM lineitem WHERE l_orderkey > 9030;
EXPLAIN (COSTS FALSE) EXECUTE real_time_executor_query; EXPLAIN (COSTS FALSE) EXECUTE real_time_executor_query;
Aggregate Aggregate
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 1 Task Count: 1
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -1078,7 +1078,7 @@ Aggregate
-- at least make sure to fail without crashing -- at least make sure to fail without crashing
PREPARE router_executor_query_param(int) AS SELECT l_quantity FROM lineitem WHERE l_orderkey = $1; PREPARE router_executor_query_param(int) AS SELECT l_quantity FROM lineitem WHERE l_orderkey = $1;
EXPLAIN EXECUTE router_executor_query_param(5); EXPLAIN EXECUTE router_executor_query_param(5);
Custom Scan (Citus Router) (cost=0.00..0.00 rows=0 width=0) Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0)
Task Count: 1 Task Count: 1
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -1098,11 +1098,11 @@ INSERT INTO lineitem_hash_part
SELECT o_orderkey FROM orders_hash_part LIMIT 3; SELECT o_orderkey FROM orders_hash_part LIMIT 3;
Custom Scan (Citus INSERT ... SELECT via coordinator) Custom Scan (Citus INSERT ... SELECT via coordinator)
-> Limit -> Limit
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 4 Task Count: 4
Tasks Shown: One of 4 Tasks Shown: One of 4
-> Task -> Task
Node: host=localhost port=57638 dbname=regression Node: host=localhost port=57637 dbname=regression
-> Limit -> Limit
-> Seq Scan on orders_hash_part_360045 orders_hash_part -> Seq Scan on orders_hash_part_360045 orders_hash_part
SELECT true AS valid FROM explain_json($$ SELECT true AS valid FROM explain_json($$
@ -1115,11 +1115,11 @@ INSERT INTO lineitem_hash_part (l_orderkey, l_quantity)
SELECT o_orderkey, 5 FROM orders_hash_part LIMIT 3; SELECT o_orderkey, 5 FROM orders_hash_part LIMIT 3;
Custom Scan (Citus INSERT ... SELECT via coordinator) Custom Scan (Citus INSERT ... SELECT via coordinator)
-> Limit -> Limit
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 4 Task Count: 4
Tasks Shown: One of 4 Tasks Shown: One of 4
-> Task -> Task
Node: host=localhost port=57638 dbname=regression Node: host=localhost port=57637 dbname=regression
-> Limit -> Limit
-> Seq Scan on orders_hash_part_360045 orders_hash_part -> Seq Scan on orders_hash_part_360045 orders_hash_part
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
@ -1127,18 +1127,27 @@ INSERT INTO lineitem_hash_part (l_orderkey)
SELECT s FROM generate_series(1,5) s; SELECT s FROM generate_series(1,5) s;
Custom Scan (Citus INSERT ... SELECT via coordinator) Custom Scan (Citus INSERT ... SELECT via coordinator)
-> Function Scan on generate_series s -> Function Scan on generate_series s
-- WHERE EXISTS forces pg12 to materialize cte
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
WITH cte1 AS (SELECT s FROM generate_series(1,10) s) WITH cte1 AS (SELECT s FROM generate_series(1,10) s)
INSERT INTO lineitem_hash_part INSERT INTO lineitem_hash_part
WITH cte1 AS (SELECT * FROM cte1 LIMIT 5) WITH cte1 AS (SELECT * FROM cte1 WHERE EXISTS (SELECT * FROM cte1) LIMIT 5)
SELECT s FROM cte1; SELECT s FROM cte1 WHERE EXISTS (SELECT * FROM cte1);
Custom Scan (Citus INSERT ... SELECT via coordinator) Custom Scan (Citus INSERT ... SELECT via coordinator)
-> CTE Scan on cte1 -> Result
One-Time Filter: $3
CTE cte1 CTE cte1
-> Function Scan on generate_series s -> Function Scan on generate_series s
CTE cte1 CTE cte1
-> Limit -> Limit
InitPlan 2 (returns $1)
-> CTE Scan on cte1 cte1_1 -> CTE Scan on cte1 cte1_1
-> Result
One-Time Filter: $1
-> CTE Scan on cte1 cte1_2
InitPlan 4 (returns $3)
-> CTE Scan on cte1 cte1_3
-> CTE Scan on cte1
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
INSERT INTO lineitem_hash_part INSERT INTO lineitem_hash_part
( SELECT s FROM generate_series(1,5) s) UNION ( SELECT s FROM generate_series(1,5) s) UNION
@ -1159,13 +1168,13 @@ series AS (
) )
SELECT l_orderkey FROM series JOIN keys ON (s = l_orderkey) SELECT l_orderkey FROM series JOIN keys ON (s = l_orderkey)
ORDER BY s; ORDER BY s;
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Output: remote_scan.l_orderkey Output: remote_scan.l_orderkey
-> Distributed Subplan 57_1 -> Distributed Subplan 57_1
-> HashAggregate -> HashAggregate
Output: remote_scan.l_orderkey Output: remote_scan.l_orderkey
Group Key: remote_scan.l_orderkey Group Key: remote_scan.l_orderkey
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Output: remote_scan.l_orderkey Output: remote_scan.l_orderkey
Task Count: 4 Task Count: 4
Tasks Shown: One of 4 Tasks Shown: One of 4

View File

@ -4,10 +4,10 @@
-- Check that we can run CREATE INDEX and DROP INDEX statements on distributed -- Check that we can run CREATE INDEX and DROP INDEX statements on distributed
-- tables. -- tables.
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS major_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
major_version server_version_above_ten
--------------- --------------------------
11 t
(1 row) (1 row)
-- --

View File

@ -4,10 +4,10 @@
-- Check that we can run CREATE INDEX and DROP INDEX statements on distributed -- Check that we can run CREATE INDEX and DROP INDEX statements on distributed
-- tables. -- tables.
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS major_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
major_version server_version_above_ten
--------------- --------------------------
10 f
(1 row) (1 row)
-- --

View File

@ -5,10 +5,10 @@
-- and that we don't partition or join prune shards that have null values. -- and that we don't partition or join prune shards that have null values.
-- print major version number for version-specific tests -- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
server_version server_version_above_ten
---------------- --------------------------
11 t
(1 row) (1 row)
SET client_min_messages TO DEBUG2; SET client_min_messages TO DEBUG2;
@ -39,7 +39,7 @@ DEBUG: Router planner does not support append-partitioned tables.
LOG: join order: [ "lineitem" ] LOG: join order: [ "lineitem" ]
QUERY PLAN QUERY PLAN
----------------------------------------------------------------------- -----------------------------------------------------------------------
Custom Scan (Citus Real-Time) Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -72,7 +72,7 @@ DEBUG: join prunable for intervals [8997,14947] and [1,5986]
QUERY PLAN QUERY PLAN
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
Aggregate Aggregate
-> Custom Scan (Citus Real-Time) -> Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -103,7 +103,7 @@ DEBUG: Router planner does not support append-partitioned tables.
LOG: join order: [ "lineitem" ] LOG: join order: [ "lineitem" ]
QUERY PLAN QUERY PLAN
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Custom Scan (Citus Real-Time) Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: All Tasks Shown: All
-> Task -> Task
@ -175,17 +175,17 @@ DEBUG: Router planner does not support append-partitioned tables.
LOG: join order: [ "lineitem" ] LOG: join order: [ "lineitem" ]
QUERY PLAN QUERY PLAN
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Custom Scan (Citus Real-Time) Custom Scan (Citus Adaptive)
Task Count: 2 Task Count: 2
Tasks Shown: All Tasks Shown: All
-> Task
Node: host=localhost port=57638 dbname=regression
-> Index Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
Index Cond: (l_orderkey = 9030)
-> Task -> Task
Node: host=localhost port=57637 dbname=regression Node: host=localhost port=57637 dbname=regression
-> Index Scan using lineitem_pkey_290001 on lineitem_290001 lineitem -> Index Scan using lineitem_pkey_290001 on lineitem_290001 lineitem
Index Cond: (l_orderkey = 9030) Index Cond: (l_orderkey = 9030)
-> Task
Node: host=localhost port=57638 dbname=regression
-> Index Scan using lineitem_pkey_290000 on lineitem_290000 lineitem
Index Cond: (l_orderkey = 9030)
(11 rows) (11 rows)
EXPLAIN (COSTS FALSE) EXPLAIN (COSTS FALSE)
@ -248,7 +248,7 @@ LOG: join order: [ "lineitem" ]
DEBUG: Plan is router executable DEBUG: Plan is router executable
QUERY PLAN QUERY PLAN
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Custom Scan (Citus Router) Custom Scan (Citus Adaptive)
Task Count: 1 Task Count: 1
Tasks Shown: All Tasks Shown: All
-> Task -> Task

View File

@ -5,10 +5,10 @@
-- and that we don't partition or join prune shards that have null values. -- and that we don't partition or join prune shards that have null values.
-- print major version number for version-specific tests -- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
server_version server_version_above_ten
---------------- --------------------------
10 f
(1 row) (1 row)
SET client_min_messages TO DEBUG2; SET client_min_messages TO DEBUG2;

View File

@ -8,10 +8,10 @@ SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 2; SET citus.shard_replication_factor TO 2;
-- print major version number for version-specific tests -- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int < 11 AS server_version_is_10;
server_version server_version_is_10
---------------- ----------------------
11 f
(1 row) (1 row)
CREATE TABLE collections ( CREATE TABLE collections (

View File

@ -8,10 +8,10 @@ SET citus.shard_count TO 4;
SET citus.shard_replication_factor TO 2; SET citus.shard_replication_factor TO 2;
-- print major version number for version-specific tests -- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int < 11 AS server_version_is_10;
server_version server_version_is_10
---------------- ----------------------
10 t
(1 row) (1 row)
CREATE TABLE collections ( CREATE TABLE collections (

View File

@ -66,9 +66,10 @@ FROM
ids_to_delete, (SELECT tenant_id FROM distributed_table WHERE tenant_id::int < 60) as some_tenants ids_to_delete, (SELECT tenant_id FROM distributed_table WHERE tenant_id::int < 60) as some_tenants
WHERE WHERE
some_tenants.tenant_id = ids_to_delete.tenant_id some_tenants.tenant_id = ids_to_delete.tenant_id
AND distributed_table.tenant_id = some_tenants.tenant_id; AND distributed_table.tenant_id = some_tenants.tenant_id
AND EXISTS (SELECT * FROM ids_to_delete);
DEBUG: generating subplan 12_1 for CTE ids_to_delete: SELECT tenant_id FROM with_dml.distributed_table WHERE (dept OPERATOR(pg_catalog.=) 5) DEBUG: generating subplan 12_1 for CTE ids_to_delete: SELECT tenant_id FROM with_dml.distributed_table WHERE (dept OPERATOR(pg_catalog.=) 5)
DEBUG: Plan 12 query after replacing subqueries and CTEs: UPDATE with_dml.distributed_table SET dept = (distributed_table.dept OPERATOR(pg_catalog.+) 1) FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_delete, (SELECT distributed_table_1.tenant_id FROM with_dml.distributed_table distributed_table_1 WHERE ((distributed_table_1.tenant_id)::integer OPERATOR(pg_catalog.<) 60)) some_tenants WHERE ((some_tenants.tenant_id OPERATOR(pg_catalog.=) ids_to_delete.tenant_id) AND (distributed_table.tenant_id OPERATOR(pg_catalog.=) some_tenants.tenant_id)) DEBUG: Plan 12 query after replacing subqueries and CTEs: UPDATE with_dml.distributed_table SET dept = (distributed_table.dept OPERATOR(pg_catalog.+) 1) FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_delete, (SELECT distributed_table_1.tenant_id FROM with_dml.distributed_table distributed_table_1 WHERE ((distributed_table_1.tenant_id)::integer OPERATOR(pg_catalog.<) 60)) some_tenants WHERE ((some_tenants.tenant_id OPERATOR(pg_catalog.=) ids_to_delete.tenant_id) AND (distributed_table.tenant_id OPERATOR(pg_catalog.=) some_tenants.tenant_id) AND (EXISTS (SELECT ids_to_delete_1.tenant_id FROM (SELECT intermediate_result.tenant_id FROM read_intermediate_result('12_1'::text, 'binary'::citus_copy_format) intermediate_result(tenant_id text)) ids_to_delete_1)))
-- this query errors out since we've some hard -- this query errors out since we've some hard
-- errors in the INSERT ... SELECT pushdown -- errors in the INSERT ... SELECT pushdown
-- which prevents to fallback to recursive planning -- which prevents to fallback to recursive planning

View File

@ -84,8 +84,8 @@ UNION
)a ORDER BY 1,2,3,4,5 LIMIT 10; )a ORDER BY 1,2,3,4,5 LIMIT 10;
-- this should fail since the cte-subplan exceeds the limit even if the -- this fails since cte-subplan exceeds limit even if cte2 and cte3 don't
-- cte2 and cte3 does not -- WHERE EXISTS forces materialization in pg12
SET citus.max_intermediate_result_size TO 4; SET citus.max_intermediate_result_size TO 4;
WITH cte AS ( WITH cte AS (
WITH cte2 AS ( WITH cte2 AS (
@ -95,8 +95,9 @@ WITH cte AS (
SELECT * FROM events_table SELECT * FROM events_table
) )
SELECT * FROM cte2, cte3 WHERE cte2.user_id = cte3.user_id AND cte2.user_id = 1 SELECT * FROM cte2, cte3 WHERE cte2.user_id = cte3.user_id AND cte2.user_id = 1
AND EXISTS (select * from cte2, cte3)
) )
SELECT * FROM cte; SELECT * FROM cte WHERE EXISTS (select * from cte);
SET citus.max_intermediate_result_size TO 3; SET citus.max_intermediate_result_size TO 3;

View File

@ -532,11 +532,12 @@ EXPLAIN (COSTS OFF)
INSERT INTO lineitem_hash_part (l_orderkey) INSERT INTO lineitem_hash_part (l_orderkey)
SELECT s FROM generate_series(1,5) s; SELECT s FROM generate_series(1,5) s;
-- WHERE EXISTS forces pg12 to materialize cte
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
WITH cte1 AS (SELECT s FROM generate_series(1,10) s) WITH cte1 AS (SELECT s FROM generate_series(1,10) s)
INSERT INTO lineitem_hash_part INSERT INTO lineitem_hash_part
WITH cte1 AS (SELECT * FROM cte1 LIMIT 5) WITH cte1 AS (SELECT * FROM cte1 WHERE EXISTS (SELECT * FROM cte1) LIMIT 5)
SELECT s FROM cte1; SELECT s FROM cte1 WHERE EXISTS (SELECT * FROM cte1);
EXPLAIN (COSTS OFF) EXPLAIN (COSTS OFF)
INSERT INTO lineitem_hash_part INSERT INTO lineitem_hash_part

View File

@ -6,7 +6,7 @@
-- tables. -- tables.
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS major_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
-- --
-- CREATE TEST TABLES -- CREATE TEST TABLES

View File

@ -8,7 +8,7 @@
-- print major version number for version-specific tests -- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int > 10 AS server_version_above_ten;
SET client_min_messages TO DEBUG2; SET client_min_messages TO DEBUG2;
SET citus.explain_all_tasks TO on; SET citus.explain_all_tasks TO on;

View File

@ -11,7 +11,7 @@ SET citus.shard_replication_factor TO 2;
-- print major version number for version-specific tests -- print major version number for version-specific tests
SHOW server_version \gset SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int AS server_version; SELECT substring(:'server_version', '\d+')::int < 11 AS server_version_is_10;
CREATE TABLE collections ( CREATE TABLE collections (

View File

@ -53,7 +53,8 @@ FROM
ids_to_delete, (SELECT tenant_id FROM distributed_table WHERE tenant_id::int < 60) as some_tenants ids_to_delete, (SELECT tenant_id FROM distributed_table WHERE tenant_id::int < 60) as some_tenants
WHERE WHERE
some_tenants.tenant_id = ids_to_delete.tenant_id some_tenants.tenant_id = ids_to_delete.tenant_id
AND distributed_table.tenant_id = some_tenants.tenant_id; AND distributed_table.tenant_id = some_tenants.tenant_id
AND EXISTS (SELECT * FROM ids_to_delete);
-- this query errors out since we've some hard -- this query errors out since we've some hard
-- errors in the INSERT ... SELECT pushdown -- errors in the INSERT ... SELECT pushdown