Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7593#discussion_r35347360
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/Analyzer.scala
 ---
    @@ -77,6 +77,7 @@ class Analyzer(
           ExtractWindowExpressions ::
           GlobalAggregates ::
           UnresolvedHavingClauseAttributes ::
    +      RemoveEvaluationFromSort ::
    --- End diff --
    
    The most optimal way is we have a perfect cost model that can predict what 
we are trading off (network vs cpu). Minus that, I think just always projecting 
is the approach that makes more sense is most common cases, because:
    
    1. It is hard to quantify the difference.
    2. I/O (network, disk) is rarely the bottleneck here, especially with more 
SSDs and 10Gbps network.
    3. Most of the time order by is just ordering by a field, and this won't 
hurt that case.
    4. If there is a complex expression, doing the eval many times during 
sorting is bad.
    
    The alternative, which is probably even better, is for the sorter itself to 
always project out the sort key. It might make more sense there, but is 
slightly more complicated to write I think.



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to