Fix condition not being moved to PREWHERE in case there is a row policy (version 2)#87303
Fix condition not being moved to PREWHERE in case there is a row policy (version 2)#87303
Conversation
|
Hey @KochetovNicolai! Great to see this issue being fixed. Will this PR also address #85834 ? |
Answering myself: Yes, it seems this PR fixes that as well. |
* Only row policy can end up not in WHERE section * Row-policy filter is never modified: No need to update it's value in the SourceStepWithFilter::updatePrewhereInfo
It was just a copy from SelectQueryInfo and it was error-prone because it's easy to forget to update it's value.
| if (prewhere_info) | ||
| { | ||
| for (const auto * input : filter_info.actions.getInputs()) | ||
| prewhere_info->prewhere_actions.tryRestoreColumn(input->result_name); | ||
| } |
There was a problem hiding this comment.
I still don't get why is it needed
There was a problem hiding this comment.
This is because additional filters may need a column which can be removed by prewhere.
Simply saying, we don't track dependency for additional filters DAG. And I don't want to, it will make the code more complicated.
There is a test which I had to fix, so added this hack.
Cherry pick #87303 to 25.9: Fix condition not being moved to PREWHERE in case there is a row policy (version 2)
… case there is a row policy (version 2)
Backport #87303 to 25.9: Fix condition not being moved to PREWHERE in case there is a row policy (version 2)
|
Thank you for this fix , can someone say if this is going to be backported also to older versions , such as 24.8 , where it seems to happen as well |
|
Yes, backport to 25.8 is wip
…________________________________
From: Roee Zilkha ***@***.***>
Sent: Sunday, October 12, 2025 10:51:45 AM
To: ClickHouse/ClickHouse ***@***.***>
Cc: Raufs Dunamalijevs ***@***.***>; Comment ***@***.***>
Subject: Re: [ClickHouse/ClickHouse] Fix condition not being moved to PREWHERE in case there is a row policy (version 2) (PR #87303)
[https://avatars.githubusercontent.com/u/17226062?s=20&v=4]rzilkha left a comment (ClickHouse/ClickHouse#87303)<#87303 (comment)>
Thank you for this fix , can someone say if this is going to be backported also to older versions , such as 24.8 , where it seems to happen as well
—
Reply to this email directly, view it on GitHub<#87303 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AHGI6CSNKQESZOYFP7BE7Q33XIJCDAVCNFSM6AAAAACG4USEUSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZTGOJUGA3TQNZYGI>.
You are receiving this because you commented.Message ID: ***@***.***>
|
This commit is a manual backport of two PRs: 1. ClickHouse#87303 2. ClickHouse#88017 Additionally, the test from ClickHouse#88036 was added.
24.8.14 Backport of ClickHouse#87303 - Fix condition not being moved to PREWHERE in case there is a row policy (version 2)
|
@rzilkha we decided against it. This is a performance improvement that touches a lot of files. Such large backport can introduce problems in a stable release |
This commit is a manual backport of two PRs:
1. ClickHouse#87303
2. ClickHouse#88017
Additionally, the test from ClickHouse#88036
was added.
Also `02679_explain_merge_tree_prewhere_row_policy` was fixed as per
0aed477
25.3.8 Backport of ClickHouse#87303 - Fix condition not being moved to PREWHERE in case there is a row policy (version 2)
…re_with_optimize_2 Fix condition not being moved to PREWHERE in case there is a row policy (version 2)
…re_with_optimize_2 Fix condition not being moved to PREWHERE in case there is a row policy (version 2)
Backport ClickHouse#87303 to 25.9: Fix condition not being moved to PREWHERE in case there is a row policy (version 2)
…llow-up Follow up to ClickHouse#87303
Backport ClickHouse#87303 to 25.9: Fix condition not being moved to PREWHERE in case there is a row policy (version 2)
…llow-up Follow up to ClickHouse#87303
25.8.15 Backport of ClickHouse#87303 - Fix condition not being moved to PREWHERE in case there is a row policy (version 2)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed move-to-prewhere optimization, which did not work in the presence of row policy.
Continuation of #85118.
Closes #69777.
Closes #83748.
Documentation entry for user-facing changes