提交 8056098e 编写于 作者: J Jesse Zhang and Omer Arap 提交者: Omer Arap

Cost model favors parallel union all [#130121327]

We enable both `serial` and `parallel union all` in the search space
and we favor `parallel union all` if the `optimizer_parallel_union`
GUC is enabled. `parallel union all` is costed as the same as maximum
costed child instead of adding the children's cost all together.

This makes the framework to choose the parallel union all instead of
serial union all when both operators are part of valid plan
alternatives.
上级 ba07d795
......@@ -95,6 +95,10 @@ namespace gpdbcost
static
CCost CostChildren(IMemoryPool *pmp, CExpressionHandle &exprhdl, const SCostingInfo *pci, ICostModelParams *pcp);
// returns cost of highest costed child
static
CCost CostMaxChild(IMemoryPool *pmp, CExpressionHandle &exprhdl, const SCostingInfo *pci, ICostModelParams *pcp);
// check if given operator is unary
static
BOOL FUnary(COperator::EOperatorId eopid);
......
......@@ -342,6 +342,40 @@ CCostModelGPDB::CostChildren
return CCost(dRes);
}
//---------------------------------------------------------------------------
// @function:
// CCostModelGPDB::CostMaxChild
//
// @doc:
// Returns cost of highest costed child
//
//---------------------------------------------------------------------------
CCost
CCostModelGPDB::CostMaxChild
(
IMemoryPool *,
CExpressionHandle &,
const SCostingInfo *pci,
ICostModelParams *
)
{
GPOS_ASSERT(NULL != pci);
DOUBLE *pdCost = pci->PdCost();
const ULONG ulSize = pci->UlChildren();
DOUBLE dRes = 0.0;
for (ULONG ul = 0; ul < ulSize; ul++)
{
if (pdCost[ul] > dRes)
{
dRes = pdCost[ul];
}
}
return CCost(dRes);
}
//---------------------------------------------------------------------------
// @function:
......@@ -695,6 +729,11 @@ CCostModelGPDB::CostUnionAll
GPOS_ASSERT(NULL != pci);
GPOS_ASSERT(NULL != CPhysicalUnionAll::PopConvert(exprhdl.Pop()));
if(COperator::EopPhysicalParallelUnionAll == exprhdl.Pop()->Eopid())
{
return CostMaxChild(pmp, exprhdl, pci, pcmgpdb->Pcp());
}
CCost costLocal = CCost(pci->DRebinds() * CostTupleProcessing(pci->DRows(), pci->DWidth(), pcmgpdb->Pcp()).DVal());
CCost costChild = CostChildren(pmp, exprhdl, pci, pcmgpdb->Pcp());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册