-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Support to set max cache size for per query in local cache #37859
Merged
kssenii
merged 28 commits into
ClickHouse:master
from
KinderRiven:support_max_request_cache_size
Jun 10, 2022
Merged
Support to set max cache size for per query in local cache #37859
kssenii
merged 28 commits into
ClickHouse:master
from
KinderRiven:support_max_request_cache_size
Jun 10, 2022
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kssenii
reviewed
Jun 5, 2022
clang-tidy failed:
|
kssenii
reviewed
Jun 6, 2022
kssenii
reviewed
Jun 7, 2022
kssenii
reviewed
Jun 8, 2022
kssenii
reviewed
Jun 10, 2022
kssenii
approved these changes
Jun 10, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
can be tested
Allows running workflows for external contributors
pr-improvement
Pull request with some product improvements
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Description
Limiting the maximum cache usage per query can effectively prevent cache pool contamination.
Related Issues
Improvement
In the figure below, we perform several small queries (SSB's Q1.1), and after the third execution we run a large query (SSB's Q2.1, which scans almost the entire table). Running large query without limiting the maximum cache usage would pollute the entire cache pool, so continuing to run Q1.1 would require re-reading data from remote S3, causing performance fluctuations.
Use and Configuration
The user can set the maximum cache usage per query with
set max_query_cache_size
before running a query.The user can set the maximum cache usage per query with
set skip_download_if_exceeds_query_cache
to decide what method to take for subsequent reads when the query cache overflows. If it is true, it will not continue to download the cache and read directly from the remote fs. If it is false, it will be replaced in the cache downloaded before the query according to the LRU strategy.Implement
Each query, when executed, requests a temporary context that holds a cached access record (LRU queue) for that query. When the query does not reach the maximum cache usage, it replaces the cache from the main cache queue in the normal way (cold data is selected from all cache blocks according to the LRU algorithm). However, when the query reaches maximum cache usage, it replaces cache blocks downloaded by the query.