-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
feat: TopNRank optimization #11554
base: main
Are you sure you want to change the base?
feat: TopNRank optimization #11554
Conversation
✅ Deploy Preview for meta-velox canceled.
|
0446e51
to
153a06f
Compare
public: | ||
MultiTopNRowNumberTest() : TopNRowNumberTest(GetParam()) {} | ||
}; | ||
|
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.
Could you also add a test case for the logic in fixTopRank
.
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.
@liujiayi771 : The fixTopRank logic is tested very thoroughly in the fewPartitions test. Have added a comment there.
@aditi-pandit So, do we need to make some abstractions in addInput here as well, to facilitate the addition of TopNStreamingRowNumber later on? |
@JkSelf : TopNRowNumber is a somewhat streaming operator in its current implementation ... It uses HashTable internally to map the input row to a partition and each partition has an accumulator that maintains the ordered rows (as many required for limit) in a priority queue. Window accumulates all the input rows and does a full sort of the input rows to demarcate into partitions and sort by order-by. So the preceding Sort was useful and we abstracted the streaming window. With TopNRowNumber, doing a full sort and then making TopNRowNumber limit to only a partition at a time, the tradeoffs are different. Have you considered removing the global sort and checking if TopNRowNumber suffices ? If we decide eventually that having a full streaming operator for topNRowNumber is useful, then it might be worth it to write a new operator itself (rather than enhance this current one). Offcourse, we can try to reuse some of the ranking logic pieces. |
@aditi-pandit I see. Thanks for your explanations. |
Design doc : https://docs.google.com/document/d/1WQfNigR9bVrbM-PqY7F0mswcetN_tdNahzD9ENye-Q0/edit?usp=sharing
#9404
The refactoring in #11440 reduces the diffs in that part of the code.
e2e Presto PR (with changes in the Presto optimizer as well) prestodb/presto#24138
Latency for SF1K TPC-DS Q67 fell from 399s to 146s with this change.
(I also started working on a fuzzer in #12103 which I will enhance for the rank and dense_rank functions added here).