[ 
https://issues.apache.org/jira/browse/HIVE-24084?focusedWorklogId=477900&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-477900
 ]

ASF GitHub Bot logged work on HIVE-24084:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 02/Sep/20 14:35
            Start Date: 02/Sep/20 14:35
    Worklog Time Spent: 10m 
      Work Description: kgyrtkirk commented on a change in pull request #1439:
URL: https://github.com/apache/hive/pull/1439#discussion_r482119043



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/cost/HiveOnTezCostModel.java
##########
@@ -89,22 +89,23 @@ public RelOptCost getAggregateCost(HiveAggregate aggregate) 
{
     } else {
       final RelMetadataQuery mq = aggregate.getCluster().getMetadataQuery();
       // 1. Sum of input cardinalities
-      final Double rCount = mq.getRowCount(aggregate.getInput());
-      if (rCount == null) {
+      final Double inputRowCount = mq.getRowCount(aggregate.getInput());
+      final Double rowCount = mq.getRowCount(aggregate);
+      if (inputRowCount == null || rowCount == null) {
         return null;
       }
       // 2. CPU cost = sorting cost
-      final double cpuCost = algoUtils.computeSortCPUCost(rCount);
+      final double cpuCost = algoUtils.computeSortCPUCost(rowCount) + 
inputRowCount * algoUtils.getCpuUnitCost();

Review comment:
       maybe...I'm trying to catch the case when `inputRowCount >> 
outputRowCount`; we are also grouping - so it will not be a full sort at all ; 
I was using the above to achieve:
   ```
   log(outputRowCount)*outputRowCount + inputRowCount*COST
   ```
   the rational behind this is that it needs to really sort `oRC` and read 
`iRC` rows - this could be an underestimation...but `log(iRC)*iRC` was highly 
overestimating the cost
   
   one alternative for the above could be to use:
   ```
   log(outputRowCount) * inputRowCount
   ```
   
   the rational behind this:
   we will need to find the place for every input row; but we also know that 
the output will be at most `outputRowCount` - so it shouldn't take more time to 
find the place for the actual row than `log(outputRowCount)`
   
   




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

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 477900)
    Time Spent: 1h  (was: 50m)

> Enhance cost model to push down more Aggregates
> -----------------------------------------------
>
>                 Key: HIVE-24084
>                 URL: https://issues.apache.org/jira/browse/HIVE-24084
>             Project: Hive
>          Issue Type: Improvement
>            Reporter: Zoltan Haindrich
>            Assignee: Zoltan Haindrich
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 1h
>  Remaining Estimate: 0h
>




--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to