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

Results WITH TOTALS were not cached in Query Cache #48677

Closed
LiyuTzyAge opened this issue Apr 12, 2023 · 4 comments · Fixed by #48853
Closed

Results WITH TOTALS were not cached in Query Cache #48677

LiyuTzyAge opened this issue Apr 12, 2023 · 4 comments · Fixed by #48853
Assignees
Labels
potential bug To be reviewed by developers and confirmed/rejected.

Comments

@LiyuTzyAge
Copy link

LiyuTzyAge commented Apr 12, 2023

You have to provide the following information whenever possible.

Describe what's wrong
When WITH TOTALS and Query Cache are used in queries, the results returned by query cache do not contain the WITH TOTALS results.

Before the query cache takes effect
:) select t1,count() from t5 group by t1 with totals order by t1 desc limit 11

┌─t1─┬─count()─┐
│ aa │ 28 │
└────┴─────────┘

Totals:
┌─t1─┬─count()─┐
│ │ 28 │
└────┴─────────┘

After the query cache takes effect

:) select t1,count() from t5 group by t1 with totals order by t1 desc limit 11

┌─t1─┬─count()─┐
│ aa │ 28 │
└────┴─────────┘

@LiyuTzyAge LiyuTzyAge added the potential bug To be reviewed by developers and confirmed/rejected. label Apr 12, 2023
@LiyuTzyAge LiyuTzyAge changed the title Results WITH TOTALS were not cached in Results WITH TOTALS were not cached in Query Cache Apr 12, 2023
@rschu1ze rschu1ze self-assigned this Apr 12, 2023
@rschu1ze
Copy link
Member

Repro:

create or replace table tbl (grp UInt64, kf UInt64) ENGINE = MergeTree order by grp;
insert into tbl values (1, 3), (2, 2), (1, 4), (1, 1);

set allow_experimental_query_cache = 1;
select grp, sum(kf) from tbl group by grp with totals SETTINGS use_query_cache = 1;
select grp, sum(kf) from tbl group by grp with totals SETTINGS use_query_cache = 1;

@rschu1ze
Copy link
Member

Same problem exists for SETTINGS extremes = 1.

@LiyuTzyAge
Copy link
Author

@rschu1ze hi, I see that the new implementation with totals will not be cached, but we use a lot of scenes, can you implement it

@rschu1ze
Copy link
Member

Yepp, I'll try

rschu1ze added a commit that referenced this issue Apr 17, 2023
Fixes: #48677

Please don't review, still contains garbage
rschu1ze added a commit that referenced this issue Apr 17, 2023
Fixes: #48677

Please don't review, still contains garbage
rschu1ze added a commit that referenced this issue Apr 19, 2023
Fixes: #48677

Please don't review, still contains garbage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
potential bug To be reviewed by developers and confirmed/rejected.
Projects
None yet
2 participants