Dandandan opened a new issue, #11900: URL: https://github.com/apache/datafusion/issues/11900
### Is your feature request related to a problem or challenge? One case where pushing down sorts is when the sort `fetch`. This will result in less input to the join, so the join will execute faster / with less memory usage. ### Describe the solution you'd like Push down sorts with fetch for joins is (at least) possible when there is no join filter and: * When sort expression is based on columns on the left side and type is left join * When sort expression is based on columns on the right side and type is right join. We should still keep the final sort on top of the result as not all planned join types will preserve the input ordering. As we have the TopK as input for join, the resulting. The other optimization rules might remove the final sort if the physical join does in fact preserve the ordering (e.g. right joins and others). The proposed optimization looks like: ``` Sort (fetch = 100) -> LeftJoin ``` ``` Sort (fetch = 100) -> Join(join_type=Left) -> Sort (fetch = 100) ``` ### Describe alternatives you've considered _No response_ ### Additional context _No response_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
