wangyum opened a new pull request, #37519:
URL: https://github.com/apache/spark/pull/37519

   ### What changes were proposed in this pull request?
   
   This PR moves `EliminateSorts` before `LimitPushDown`. 
   
   ### Why are the changes needed?
   
   Eliminate more sorts to improve query performance. For example:
   ```sql
   SELECT *                                
   FROM   (SELECT *                        
           FROM   testdata                 
           ORDER  BY key) t1               
          CROSS JOIN (SELECT *             
                      FROM   testdata2     
                      ORDER  BY a) t2      
   LIMIT  2                                
   ```
   
   Before this PR:
   ```
   == Optimized Logical Plan ==
   GlobalLimit 2
   +- LocalLimit 2
      +- Join Cross
         :- LocalLimit 2
         :  +- Sort [key#13 ASC NULLS FIRST], true
         :     +- SerializeFromObject [TestData]
         :        +- ExternalRDD [obj#12]
         +- LocalLimit 2
            +- Sort [a#23 ASC NULLS FIRST], true
               +- SerializeFromObject [TestData2]
                  +- ExternalRDD [obj#22]
   ```
   After this PR:
   ```
   == Optimized Logical Plan ==
   GlobalLimit 2
   +- LocalLimit 2
      +- Join Cross
         :- LocalLimit 2
         :  +- SerializeFromObject [TestData]
         :     +- ExternalRDD [obj#12]
         +- LocalLimit 2
            +- SerializeFromObject [TestData2]
               +- ExternalRDD [obj#22]
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   
   No.
   
   ### How was this patch tested?
   
   Unit test.


-- 
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]

Reply via email to