Thomas Tauber-Marshall has posted comments on this change.

Change subject: IMPALA-2805: Order filters based on selectivity and cost
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/2598/1/fe/src/main/java/com/cloudera/impala/planner/PlanNode.java
File fe/src/main/java/com/cloudera/impala/planner/PlanNode.java:

Line 667:         double cost = e.getCost() + (totalCost - e.getCost()) * 
e.getSelectivity();
> Where is the data type used in cost formula? sorry I couldn't find it. 
It comes from NumericLiteral::computeCost, StringLiteral::computeCost, etc.

So in your example, "age in (10,12,13)"'s cost would be computed as:

cost = (in predicate cost)
= (children's cost) + (comparison cost) + (in cost)
= cost(age) + cost(10) + cost(12) + cost(13) + binary_predicate_cost * 3 + 
in_cost
= slot_ref_cost + int_literal_cost + int_literal_cost + int_literal_cost + 
binary_predicate_cost * 3 + in_cost
= 5 + 1 + 1 + 1 + 1 * 3 + 5
= 16

and "city in ('NY', "SF")"'s cost would be:
cost = (in predicate cost)
= (children's cost) + (comparison cost) + (in cost)
= cost(city) + cost('New York') + cost('San Francisco') + binary_predicate_cost 
* 2 + in_cost
= slot_ref_cost + string_literal_cost + string_literal_cost + 
binary_predicate_cost * 2 + in_cost
= 5 + 8 + 13 + 1 * 2 + 5
= 33

Of course, these estimates are not perfect, but they should give us better 
ordering than the essentially random ordering that we have now.


-- 
To view, visit http://gerrit.cloudera.org:8080/2598
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I02279a26fbc6308ac5eb819d78345fc010469034
Gerrit-PatchSet: 1
Gerrit-Project: Impala
Gerrit-Branch: cdh5-trunk
Gerrit-Owner: Thomas Tauber-Marshall <[email protected]>
Gerrit-Reviewer: Alex Behm <[email protected]>
Gerrit-Reviewer: Marcel Kornacker <[email protected]>
Gerrit-Reviewer: Matthew Jacobs <[email protected]>
Gerrit-Reviewer: Mostafa Mokhtar <[email protected]>
Gerrit-Reviewer: Thomas Tauber-Marshall <[email protected]>
Gerrit-HasComments: Yes

Reply via email to