onur-leftjoin_push-improvements
eaydingol 2025-07-31 16:43:29 +03:00
parent afd3bd921d
commit bca534cb3e
2 changed files with 26 additions and 0 deletions

View File

@ -34,6 +34,14 @@ CREATE TABLE d1_local(like d1);
INSERT INTO d1_local select * from d1;
CREATE TABLE d2_local(like d2);
INSERT INTO d2_local select * from d2;
SET citus.shard_count TO 2;
CREATE TABLE d3_not_colocated(like d1);
SELECT create_distributed_table('d3_not_colocated', 'a');
create_distributed_table
---------------------------------------------------------------------
(1 row)
SET client_min_messages TO DEBUG3;
-- Basic test cases
-- Test that the join is pushed down to the worker nodes, using "using" syntax
@ -116,6 +124,14 @@ SELECT count(*) FROM r1_local LEFT JOIN d1_local USING (b);
16
(1 row)
-- Test that the join is not pushed down when we have non-colocated tables in the RHS
SELECT count(*) FROM r1 LEFT JOIN (SELECT d1.a, d3_not_colocated.b FROM d3_not_colocated FULL JOIN d1 ON d3_not_colocated.a = d1.a) USING (a);
ERROR: cannot push down this subquery
DETAIL: d3_not_colocated and d1 are not colocated
-- The same error with its RIGHT JOIN variant
SELECT count(*) FROM r1 LEFT JOIN (SELECT d1.a, d3_not_colocated.b FROM d3_not_colocated JOIN d1 ON d3_not_colocated.a = d1.a) USING (a);
ERROR: cannot push down this subquery
DETAIL: d3_not_colocated and d1 are not colocated
-- Basic test cases with ON syntax
-- Test that the join is pushed down to the worker nodes, using "on" syntax
SET client_min_messages TO DEBUG3;

View File

@ -27,6 +27,11 @@ INSERT INTO d1_local select * from d1;
CREATE TABLE d2_local(like d2);
INSERT INTO d2_local select * from d2;
SET citus.shard_count TO 2;
CREATE TABLE d3_not_colocated(like d1);
SELECT create_distributed_table('d3_not_colocated', 'a');
SET client_min_messages TO DEBUG3;
-- Basic test cases
@ -42,6 +47,11 @@ SET client_min_messages TO DEBUG1;
SELECT count(*) FROM r1 LEFT JOIN d1 USING (b);
SELECT count(*) FROM r1_local LEFT JOIN d1_local USING (b);
-- Test that the join is not pushed down when we have non-colocated tables in the RHS
SELECT count(*) FROM r1 LEFT JOIN (SELECT d1.a, d3_not_colocated.b FROM d3_not_colocated FULL JOIN d1 ON d3_not_colocated.a = d1.a) USING (a);
-- The same error with its RIGHT JOIN variant
SELECT count(*) FROM r1 LEFT JOIN (SELECT d1.a, d3_not_colocated.b FROM d3_not_colocated JOIN d1 ON d3_not_colocated.a = d1.a) USING (a);
-- Basic test cases with ON syntax
-- Test that the join is pushed down to the worker nodes, using "on" syntax
SET client_min_messages TO DEBUG3;