-
Notifications
You must be signed in to change notification settings - Fork 3.7k
branch-3.0: [opt](nereids) optimize normalize window (#54947) #55045
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
branch-3.0: [opt](nereids) optimize normalize window (#54947) #55045
Conversation
close apache#54577 optimize normalize window, only push down the expression's used slots to bottom projects, which the expression not contains WindowFunction, so we can push down more filter through window. for this sql: ```sql select SUBSTR(orderdate,1,10) AS dt, ROW_NUMBER() OVER(PARTITION BY orderdate ORDER BY orderid DESC) AS rn from lineorders having dt = '2025-01-01' ``` we not push down the `dt` slot under LogicalWindow, but push down [orderdate, orderid] to the bottom projects, because if we push down `dt`, the plan tree will be: ``` LogicalFilter(substr(dt#3, 1, 10) = '2025-01-01') | LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1)) | LogicalProject(orderid#1, orderdate#2, substr(orderdate#1, 1, 10) as dt#3) ``` and can not push down filter by `PushDownFilterThroughWindow`, causing inefficiency, because dt#3 in LogicalFilter not contains in the partition key in LogicalWindow: [orderdate#2]. so we only push down orderdate in the LogicalFilter, not push down `dt`: ``` LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01') | LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1)) | LogicalProject(orderid#1, orderdate#2) ``` and then, `PushDownFilterThroughWindow` found the LogicalFilter's `orderdate#2` contains in the LogicalWindow's partition key: [orderdate#2], and can push down filter to: ``` LogicalWindow(rowNumber(partition by orderdate#2, order by orderid#1)) | LogicalProject(orderid#1, orderdate#2) | LogicalFilter(substr(orderdate#2, 1, 10) = '2025-01-01') ``` (cherry picked from commit 0e669b9)
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
|
run buildall |
TPC-H: Total hot run time: 40080 ms |
TPC-DS: Total hot run time: 192765 ms |
ClickBench: Total hot run time: 30.33 s |
FE UT Coverage ReportIncrement line coverage |
|
run buildall |
TPC-H: Total hot run time: 39641 ms |
TPC-DS: Total hot run time: 191902 ms |
ClickBench: Total hot run time: 30.24 s |
FE UT Coverage ReportIncrement line coverage |
dataroaring
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cherry pick from #54947