Refactor cache key calculation for joins#76613
Merged
Conversation
Contributor
Member
Author
|
|
KochetovNicolai
approved these changes
Feb 26, 2025
|
|
||
| const JoinSettings & getSettings() const { return join_settings; } | ||
|
|
||
| void setHashTableCacheKeys(UInt64 left_key_hash, UInt64 right_key_hash) |
Member
There was a problem hiding this comment.
We are planning to support multiple tables in the JoinLocial step in the future.
It's ok to keep it here for now.
Another option: do it for the JoinStep (physical one), cause JoinStepLogical is converted to (potentially many) JoinStep (physical).
src/Processors/QueryPlan/Optimizations/calculateHashTableCacheKeys.cpp
Outdated
Show resolved
Hide resolved
| catch (const Exception & e) | ||
| { | ||
| // Some steps currently missing serialization support. Let's just skip them. | ||
| if (e.code() != ErrorCodes::NOT_IMPLEMENTED) |
Member
There was a problem hiding this comment.
Hmm, that's not nice to rethrow/catch exceptions in normal query execution. Can we avoid it, please?
| writeStringBinary(transform.getSerializationName(), wbuf); | ||
| try | ||
| { | ||
| transform.serialize(ctx); |
Member
There was a problem hiding this comment.
I would definitely prefer to add bool IQueryPlanStep::updateHash() virtual method and implement it for some steps (probably, even via serializaion).
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.
Changelog category (leave one):
As of now, we calculate keys for
HashTablesStatistics(cache of hash table sizes for aggregation and joins) mainly from the AST. It has drawbacks. Namely, it doesn't account for all the changes that happen in the planning stage (filters push down, reordering, and so on). Also, we want to use statistics from this cache for optimization itself (e.g. #76185). The bottom line is we better to reimplement this logic in a proper way.