-
Notifications
You must be signed in to change notification settings - Fork 69
Closed
@dimarick
Description
Schema and data:
create table parent ( id SERIAL NOT NULL, owner_id INTEGER NOT NULL ); create table child ( parent_id INTEGER NOT NULL, owner_id INTEGER NOT NULL ); create table child_nopart ( parent_id INTEGER NOT NULL, owner_id INTEGER NOT NULL ); insert into parent (owner_id) values (1), (2), (3), (3); insert into child (parent_id, owner_id) values (1, 1), (2, 2), (3, 3), (5, 3); insert into child_nopart (parent_id, owner_id) values (1, 1), (2, 2), (3, 3), (5, 3); select create_hash_partitions('child', 'owner_id', 2);
The select SQL to reproduce:
select * from parent left join child on child.parent_id = parent.id and child.owner_id = parent.owner_id where parent.owner_id = 3 and parent.id in (3, 4);
Actual result:
id owner_id parent_id owner_id
3 3 3 3
3 3 5 3
4 3 3 3
4 3 5 3
https://explain.depesz.com/s/ioD5K
All of this will work as expected:
select * from parent left join child on child.parent_id = parent.id and child.owner_id = 3 where parent.owner_id = 3 and parent.id in (3, 4); select * from parent left join child_1 child on child.parent_id = parent.id and child.owner_id = parent.owner_id where parent.owner_id = 3 and parent.id in (3, 4); select * from parent left join child_nopart child on child.parent_id = parent.id and child.owner_id = parent.owner_id where parent.owner_id = 3 and parent.id in (3, 4); select * from parent left join child on child.parent_id = parent.id and child.owner_id = parent.owner_id where parent.owner_id = 3;
Result:
id owner_id parent_id owner_id
3 3 3 3
4 3 <null> <null>
Affected version 1.3.2