You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Γιώργος Θεοδωράκης <gi...@gmail.com> on 2017/05/02 14:23:14 UTC
CumulativeCost not working while searching for the optimal plan in Volcano
Hello,
I am trying to implement a cost model, in which some parameters are
computed based on estimations made by their children. For example, if I
have Filter2(Filter1(Scan)), I want to use the cpu estimation I have from
Filter1 to compute the cost parameters of Filter2 operator.
Code from Filter computeSelfCost method:
@Override public RelOptCost computeSelfCost(RelOptPlanner planner,
RelMetadataQuery m
double rowCount = mq.getRowCount(this);
double selectivity = mq.getSelectivity(this.getInput(),
this.getCondition());
double rate = selectivity * ((SaberCostBase)
mq.getCumulativeCost(this.getInput())).getRate();
double cpuCost = SaberCostBase.Cs * rate;
double window = selectivity * ((SaberCostBase)
mq.getCumulativeCost(this.getInput())).getWindow();
window = (window < 1) ? 1 : window; // fix window size in order to be >= 1
double R = (((SaberCostBase)
mq.getCumulativeCost(this.getInput())).getCpu() + cpuCost) / rate;
SaberCostFactory costFactory = (SaberCostFactory)planner.getCostFactory();
return costFactory.makeCost(rowCount, cpuCost, 0, rate, 0, window, R);
}
When I compute the cumulative cost on my final plan I get correct
estimations. However, I found out with checkpoints, that when I use Volcano
Optimizer to enforce some rules, both
((SaberCostBase) mq.getCumulativeCost(this.getInput())).getRate() and
((SaberCostBase) mq.getCumulativeCost(this.getInput())).getCpu() return
zeros instead of the correct number. By inspecting "this" variable, I
discovered that the correct estimations can be found in
this->input->bestCost, which I can't use.
Is there any obvious way of accessing the estimations of the previous
operators, while using Volcano optimization procedure? Is it somehow
possible to do it?
Thank you in advance,
George