版本:2.1.8
CREATE TABLE test_cg_column_order1 (k1 date, k2 int, k3 int, v1 int) PARTITION BY RANGE(`k1`) (
PARTITION p1 VALUES LESS THAN('2025-03-20'),
PARTITION p2 VALUES LESS THAN('2025-03-21')
) DISTRIBUTED BY HASH(k2, k3) BUCKETS 8 PROPERTIES("colocate_with" = "group3");
insert into test_cg_column_order1 values ('2024-03-21', 1, 2, 3);
insert into test_cg_column_order1 values ('2024-03-20', 4, 5, 6);
CREATE TABLE test_cg_column_order2 (k1 date, k2 int, k3 int, v1 int) DISTRIBUTED BY HASH(k2, k3) BUCKETS 8 PROPERTIES("colocate_with" = "group3");
insert into test_cg_column_order2 values ('2024-03-20', 1, 2, 3);
使用1个分桶列k2,走的shuffle join
explain select * from test_cg_column_order1 a inner join test_cg_column_order2 b on a.k2 = b.k2
使用2个分桶列k2和k3,走的colcation join
explain select * from test_cg_column_order1 a inner join test_cg_column_order2 b on a.k2 = b.k2 and a.k3 = b.k3