Query cache: Enable compression of cache entries#45912
Merged
Conversation
ebc6759 to
0c70d0c
Compare
b7e30f2 to
2db2fba
Compare
2db2fba to
6aa4fb2
Compare
6aa4fb2 to
4afd391
Compare
ClickHouse reads table data in blocks of 'max_block_size' rows. Due to filtering, aggregation, etc., result blocks are typically much smaller than 'max_block_size' but there are also cases where they are much bigger. Setting 'query_cache_squash_partial_results' (enabled by default) now controls if result blocks are squashed (if they are tiny) or split (if they are large) into blocks of 'max_block_size' size before insertion into the query result cache. This reduces performance of writes into the query cache but improves compressability of cache entries and provides more natural block granularity when query results are later served from the query cache. Entries in the query cache are now also compressed by default. This reduces the overall memory consumption at the cost of slower writes into / reads from the query cache. To disable compression, use setting 'query_cache_compress_entries'.
4afd391 to
d849378
Compare
Member
|
See #48358 (comment). |
rschu1ze
added a commit
that referenced
this pull request
Apr 3, 2023
Failing with high rate in master after #45912 was merged
devcrafter
reviewed
Apr 3, 2023
|
|
||
| -- Create test table with lot's of rows | ||
| CREATE TABLE t(c String) ENGINE=MergeTree ORDER BY c; | ||
| INSERT INTO t values ('abc') ('def') ('abc') ('jkl'); |
Member
There was a problem hiding this comment.
Please
INSERT INTO t SELECT multiIf(n = 0, 'abc', n = 1, 'def', n = 2, 'abc', 'jkl')
FROM
(
SELECT number % 4 AS n
FROM numbers(4 * 400)
)
rschu1ze
added a commit
that referenced
this pull request
Apr 4, 2023
- clear query cache at the end of the tests to minimize interaction with other query cache tests - generate data more elegantly
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR changes two things in the query cache:
ClickHouse reads table data in blocks of
max_block_sizerows but due to filtering, aggregation, etc., result blocks are typically much smaller thanmax_block_size(and sometimes bigger). The new settingquery_cache_squash_partial_results(enabled by default) now controls if result blocks are squashed (if they are tiny) or split (if they are large) into blocks ofmax_block_sizesize before insertion into the query result cache. This reduces performance of writes into the query cache but improves compressability of cache entries and provides a "natural" block granularity when query results are later served from the query cache.Entries in the query cache are now compressed by default. This reduces the overall memory consumption at the cost of slower writes into / reads from the query cache. To disable compression, use the new setting
query_cache_compress_entries.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Entries in the query cache are now squashed to max_block_size and compressed