分类: 数据库开发技术
2015-02-11 14:10:04
Netezza -- join columns of the 2 table should be same dataType , or there will be data distribution or broadcast
create table test_a (id int) distribute on (id);
create table test_b (id char(10)) distribute on (id);
insert into test_a values (1001);
insert into test_b values ('1001');
select count(*),datasliceid from test_a group by datasliceid;
-- 1 42
select count(*),datasliceid from test_b group by datasliceid;
-- 2 10
select a.id from test_b b , test_a a where a.id = b.id ;
QUERY SQL:
explain verbose select a.id from test_b b , test_a a where a.id = b.id
QUERY VERBOSE PLAN:
Node 1.
[SPU Sequential Scan table "TEST_A" as "A" {(A."ID")}]
-- Estimated Rows = 1, Width = 4, Cost = 0.0 .. 0.0, Conf = 80.0
Restrictions:
(A."ID" NOTNULL)
Projections:
1:A."ID"
[SPU Broadcast]
[HashIt for Join]
Node 2.
[SPU Sequential Scan table "TEST_B" as "B" {(B."ID")}]
-- Estimated Rows = 1, Width = 4, Cost = 0.0 .. 0.0, Conf = 80.0
Restrictions:
(B."ID" NOTNULL)
Projections:
1:INT4((B."ID")::"VARCHAR")
Node 3.
[SPU Hash Join Stream "Node 2" with Temp "Node 1" {(B."ID")}]
-- Estimated Rows = 1, Width = 4, Cost = 0.0 .. 0.0, Conf = 64.0
Restrictions:
(EXPR."INT4((B."ID")::"VARCHAR")" = A."ID")
Projections:
1:A."ID"
[SPU Return]
[Host Return]