Repository navigation
Take amount of filtered into account for query_plan_join_swap_table - #73534
Conversation
|
This is an automated comment for commit 1f4c18b with description of existing statuses. It's updated for the latest CI running ❌ Click here to open a full report in a separate page
Successful checks
|
There was a problem hiding this comment.
There can be extreme cases, e.g. just 1 out of 1 million granules is eliminated by the index lookup which is equal to not doing an index lookup at all.
Not sure but maybe it makes sense to avoid this by adding a "usefulness" threshold, e.g. 90% of granules are filtered out?
There was a problem hiding this comment.
The important part is that we get a number of rows close to the estimated one. My assumption was that if we either don’t touch the columns with an index at all (in which case we have no idea how much data is filtered and therefore don’t make any estimation), or if the index is applied, we likely won’t filter much data using this filter at runtime.
Of course, we can have multiple filters or issues with granularity, and it could still be the case. But I’m not sure if a threshold would really help here. What’s more important is that the estimation is lower than the estimation for another table. Perhaps we could set a threshold for that instead.
There was a problem hiding this comment.
As far as I see if the index_stats is not empty, it will always contain IndexType::None as a first item (because MergeTreeDataSelectExecutor::filterPartsByPartition is always called before MergeTreeDataSelectExecutor::filterPartsByPrimaryKeyAndSkipIndexes, and the former one always puts an IndexType::None into the index_stats result and I couldn't find any other place where we populate a vector like that.
Am I right? If yes, then I think the code is okay, but it might worth to add a comment about it. If I am mistaken, then we might have have some issues if IndexType::None can come after any other index.
There was a problem hiding this comment.
In my understanding, that’s the case. I added a comment stating that we expect IndexType::None as the first element. If that’s not true, we won’t apply the optimization. I suppose it’s alright to stay conservative in this case.
7ec5412 to
80b1baf
Compare
#64838 ? |
…ery_plan_join_swap_table
Backport #73534 to 24.12: Take amount of filtered into account for query_plan_join_swap_table
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
...