Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi-way hash/merge joins are impossible for expression-based keys #7164

Closed
dyemanov opened this issue Apr 2, 2022 · 0 comments
Closed

Comments

@dyemanov
Copy link
Member

dyemanov commented Apr 2, 2022

Consider example:

create table t1 (id int);
create table t2 (id int);
create table t3 (id int);
commit;

set plan;

select *
from t1, t2, t3
where t1.id = t2.id and t2.id = t3.id;
-- PLAN HASH (T1 NATURAL, T2 NATURAL, T3 NATURAL)

i.e. all three streams are joined in one pass.
Now let's replace joined fields with expressions:

select *
from t1, t2, t3
where t1.id+0 = t2.id+0 and t2.id+0 = t3.id+0;
-- PLAN HASH (HASH (T1 NATURAL, T2 NATURAL), T3 NATURAL)

i.e. two joins are used instead of one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment