pull/7643/head
paragjain 2024-07-13 07:24:44 +00:00
parent 98ac3aa938
commit 9243b5992b
3 changed files with 66 additions and 60 deletions

View File

@ -81,19 +81,19 @@ SELECT * FROM target;
(2 rows)
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
QUERY PLAN
QUERY PLAN
---------------------------------------------------------------------
Custom Scan (Citus MERGE INTO ...) (cost=0.00..0.00 rows=0 width=0)
Custom Scan (Citus MERGE INTO ...)
MERGE INTO target method: pull to coordinator
-> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Adaptive)
Task Count: 1
Tasks Shown: All
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000000 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000000 source
(8 rows)
DROP TABLE IF EXISTS source;
@ -151,19 +151,19 @@ SELECT * FROM target;
(2 rows)
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
QUERY PLAN
QUERY PLAN
---------------------------------------------------------------------
Custom Scan (Citus MERGE INTO ...) (cost=0.00..0.00 rows=0 width=0)
Custom Scan (Citus MERGE INTO ...)
MERGE INTO target method: pull to coordinator
-> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0)
-> Custom Scan (Citus Adaptive)
Task Count: 1
Tasks Shown: All
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000002 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000002 source
(8 rows)
DROP TABLE IF EXISTS source;
@ -221,28 +221,28 @@ SELECT * FROM target;
(2 rows)
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
QUERY PLAN
QUERY PLAN
---------------------------------------------------------------------
Custom Scan (Citus MERGE INTO ...) (cost=0.00..0.00 rows=0 width=0)
Custom Scan (Citus MERGE INTO ...)
MERGE INTO target method: pull to coordinator
-> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=100000 width=40)
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: All
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000007 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000007 source
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000008 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000008 source
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000009 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000009 source
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000010 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000010 source
(17 rows)
DROP TABLE IF EXISTS source;
@ -300,28 +300,28 @@ SELECT * FROM target;
(2 rows)
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
QUERY PLAN
QUERY PLAN
---------------------------------------------------------------------
Custom Scan (Citus MERGE INTO ...) (cost=0.00..0.00 rows=0 width=0)
Custom Scan (Citus MERGE INTO ...)
MERGE INTO target method: repartition
-> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=100000 width=40)
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: All
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000012 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000012 source
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000013 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000013 source
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000014 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000014 source
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000015 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000015 source
(17 rows)
DROP TABLE IF EXISTS source;
@ -379,28 +379,28 @@ SELECT * FROM target;
(2 rows)
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
QUERY PLAN
QUERY PLAN
---------------------------------------------------------------------
Custom Scan (Citus MERGE INTO ...) (cost=0.00..0.00 rows=0 width=0)
Custom Scan (Citus MERGE INTO ...)
MERGE INTO target method: repartition
-> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=100000 width=40)
-> Custom Scan (Citus Adaptive)
Task Count: 4
Tasks Shown: All
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000020 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000020 source
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000021 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000021 source
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000022 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000022 source
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Seq Scan on source_4000023 source (cost=0.00..22.00 rows=1200 width=40)
-> Seq Scan on source_4000023 source
(17 rows)
DROP TABLE IF EXISTS source;
@ -458,21 +458,21 @@ SELECT * FROM target;
(2 rows)
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
QUERY PLAN
QUERY PLAN
---------------------------------------------------------------------
Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0)
Custom Scan (Citus Adaptive)
Task Count: 1
Tasks Shown: All
-> Task
Node: host=localhost port=xxxxx dbname=regression
-> Merge on target_4000029 target (cost=0.00..137.01 rows=0 width=0)
-> Nested Loop (cost=0.00..137.01 rows=7200 width=6)
-> Seq Scan on source_4000028 source (cost=0.00..22.00 rows=1200 width=0)
-> Materialize (cost=0.00..25.03 rows=6 width=6)
-> Seq Scan on target_4000029 target (cost=0.00..25.00 rows=6 width=6)
-> Merge on target_4000029 target
-> Nested Loop
-> Seq Scan on source_4000028 source
-> Materialize
-> Seq Scan on target_4000029 target
Filter: ('2'::bigint = id)
(11 rows)

View File

@ -0,0 +1,6 @@
SHOW server_version \gset
SELECT substring(:'server_version', '\d+')::int >= 15 AS server_version_ge_15
\gset
\if :server_version_ge_15
\else
\q

View File

@ -43,7 +43,7 @@ SELECT create_distributed_table('target', null, colocate_with=>'none');
INSERT INTO source (id, doc) VALUES (1, '{"a" : 1}'), (1, '{"a" : 2}');
-- insert
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -54,7 +54,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- update
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -65,7 +65,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
@ -91,7 +91,7 @@ SELECT create_distributed_table('target', 'id');
INSERT INTO source (id, doc) VALUES (1, '{"a" : 1}'), (1, '{"a" : 2}');
-- insert
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -102,7 +102,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- update
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -113,7 +113,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
@ -140,7 +140,7 @@ SELECT create_distributed_table('target', null);
INSERT INTO source (id, doc) VALUES (1, '{"a" : 1}'), (1, '{"a" : 2}');
-- insert
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -151,7 +151,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- update
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -162,7 +162,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
@ -187,7 +187,7 @@ SELECT create_distributed_table('target', 'id');
INSERT INTO source (id, doc) VALUES (1, '{"a" : 1}'), (1, '{"a" : 2}');
-- insert
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -198,7 +198,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- update
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -209,7 +209,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
@ -235,7 +235,7 @@ SELECT create_distributed_table('target', 'id', colocate_with=>'source');
INSERT INTO source (id, doc) VALUES (1, '{"a" : 1}'), (1, '{"a" : 2}');
-- insert
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -246,7 +246,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- update
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -257,7 +257,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;
@ -283,7 +283,7 @@ SELECT create_distributed_table('target', null, colocate_with=>'source');
INSERT INTO source (id, doc) VALUES (1, '{"a" : 1}'), (1, '{"a" : 2}');
-- insert
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -294,7 +294,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- update
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id) AND src.doc = target.doc
WHEN MATCHED THEN
UPDATE SET doc = '{"b" : 1}'
@ -305,7 +305,7 @@ VALUES (src.t_id, doc);
SELECT * FROM target;
-- Explain
EXPLAIN MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
EXPLAIN (costs off, timing off, summary off) MERGE INTO ONLY target USING (SELECT 2::bigint AS t_id, doc FROM source) src
ON (src.t_id = target.id)
WHEN MATCHED THEN DO NOTHING;