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

Engine Merge with Join does not use partition key / primary key #22226

Closed
den-crane opened this issue Mar 28, 2021 · 2 comments · Fixed by #21370
Closed

Engine Merge with Join does not use partition key / primary key #22226

den-crane opened this issue Mar 28, 2021 · 2 comments · Fixed by #21370
Assignees

Comments

@den-crane
Copy link
Contributor

den-crane commented Mar 28, 2021

20.8.14.4
affected all versions after #15228 #15242

create table foo(A Int64, V Int64, S String) Engine=MergeTree partition by V order by A;
insert into foo select number, number%5, '' from numbers(100000);
create table foo_merge as foo ENGINE=Merge(currentDatabase(), '^foo');

select count(), B from foo_merge join 
   (select materialize('') as S, 5 B) x using S 
where V = 4 
group by B

Key condition: unknown
MinMax index condition: unknown
Selected 5 parts by date, 5 parts by key, 15 marks by primary key, 15 marks to read from 5 ranges

Processed 100.00 thousand rows

select count(), B from foo_merge join 
   (select materialize('') as S, 5 B) x using S 
where V = 4 and A = 4 
group by B 

Key condition: unknown
MinMax index condition: unknown
Selected 5 parts by date, 5 parts by key, 15 marks by primary key, 15 marks to read from 5 ranges

Processed 100.00 thousand rows

without merge

select count(), B from foo join 
   (select materialize('') as S, 5 B) x using S 
where V = 4 and A = 4 
group by B 

Key condition: unknown, (column 0 in [4, 4]), and
MinMax index condition: (column 0 in [4, 4]), unknown, and
Selected 1 parts by date, 1 parts by key, 1 marks by primary key, 1 marks to read from 1 ranges
Processed 8.19 thousand rows

WA (subquery):

select count(), B from (select * from foo_merge) f join 
   (select materialize('') as S, 5 B) x using S 
where V = 4 and A = 4 
group by B 

Key condition: (column 0 in [4, 4]), unknown, and
MinMax index condition: unknown, (column 0 in [4, 4]), and
Selected 1 parts by date, 1 parts by key, 1 marks by primary key, 1 marks to read from 1 ranges
Processed 8.19 thousand rows
@filimonov
Copy link
Contributor

I think it has the same nature as #18368 (comment)

@filimonov
Copy link
Contributor

/cc @vdimir

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

Successfully merging a pull request may close this issue.

3 participants