You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/09/18 11:53:24 UTC

[GitHub] [arrow-datafusion] Dandandan commented on issue #3516: Support Top-K query optimization for `ORDER BY [ASC|DESC] LIMIT n`

Dandandan commented on issue #3516:
URL: https://github.com/apache/arrow-datafusion/issues/3516#issuecomment-1250253694

   I think there are two 
   
   * parallelizing `order by` followed by `limit n`:
   
   Currently a plan looks like the following
   
   ```
   | physical_plan | GlobalLimitExec: skip=0, fetch=10                                                                                                                                                                                                                            |
   |               |   SortExec: [COUNT(UInt8(1))@3 DESC]                                                                                                                                                                                                                         |
   ```
    
   I think we should be translating it to:
   
   ```
   | physical_plan | GlobalLimitExec: skip=0, fetch=10                                                                                                                                                                                                                            |
   |               |   SortExec: [COUNT(UInt8(1))@3 DESC]                                                                                                                                                                                                                         |
   |               |     CoalescePartitionsExec                                                                                                                                                                                                                                   |
   ```
   Already with the current implementation we should be able to rewrite it to:
   
   ```
   | physical_plan | GlobalLimitExec: skip=0, fetch=10                                                                                                                                                                                                                            |
   |               |   SortExec: mode=Global [COUNT(UInt8(1))@3 DESC]                                                                                                                                                                                                                         |
   |               |     CoalescePartitionsExec                                                                                                                                                                                                                                   |
   |               |        LocalLimitExec: skip=0, fetch=10                                                                                                                                                                                                                                   |
   |               |          SortExec: mode=Local [COUNT(UInt8(1))@3 DESC]
   
   
   ```


-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org