-- -- NON_COLOCATED_JOIN_ORDER -- -- Tests to check placements of shards must be equal to choose local join logic. CREATE TABLE test_table_1(id int, value_1 int); SELECT master_create_distributed_table('test_table_1', 'id', 'append'); master_create_distributed_table --------------------------------------------------------------------- (1 row) \copy test_table_1 FROM STDIN DELIMITER ',' \copy test_table_1 FROM STDIN DELIMITER ',' CREATE TABLE test_table_2(id int, value_1 int); SELECT master_create_distributed_table('test_table_2', 'id', 'append'); master_create_distributed_table --------------------------------------------------------------------- (1 row) \copy test_table_2 FROM STDIN DELIMITER ',' \copy test_table_2 FROM STDIN DELIMITER ',' SET citus.log_multi_join_order to TRUE; SET client_min_messages to DEBUG1; SET citus.enable_repartition_joins TO on; -- when joining append tables we always get dual re-partition joins SELECT count(*) FROM test_table_1, test_table_2 WHERE test_table_1.id = test_table_2.id; LOG: join order: [ "test_table_1" ][ dual partition join "test_table_2" ] count --------------------------------------------------------------------- 6 (1 row) -- Add two shards placement of interval [8,10] to test_table_1 SET citus.shard_replication_factor to 2; \copy test_table_1 FROM STDIN DELIMITER ',' -- Add two shards placement of interval [8,10] to test_table_2 SET citus.shard_replication_factor to 1; \copy test_table_2 FROM STDIN DELIMITER ',' -- Although shard interval of relation are same, since they have different amount of placements -- for interval [8,10] repartition join logic will be triggered. SET citus.enable_repartition_joins to ON; SELECT count(*) FROM test_table_1, test_table_2 WHERE test_table_1.id = test_table_2.id; LOG: join order: [ "test_table_1" ][ dual partition join "test_table_2" ] count --------------------------------------------------------------------- 9 (1 row) SET client_min_messages TO default; DROP TABLE test_table_1; DROP TABLE test_table_2;