//--------------------------------------------------------------------------- // @function: // CLogicalDifferenceAll::PstatsDerive // // @doc: // Derive statistics // //--------------------------------------------------------------------------- IStatistics * CLogicalDifferenceAll::PstatsDerive ( IMemoryPool *pmp, CExpressionHandle &exprhdl, DrgPstat * // not used ) const { GPOS_ASSERT(Esp(exprhdl) > EspNone); // difference all is transformed into a LASJ, // we follow the same route to compute statistics DrgPcrs *pdrgpcrsOutput = GPOS_NEW(pmp) DrgPcrs(pmp); const ULONG ulSize = m_pdrgpdrgpcrInput->UlLength(); for (ULONG ul = 0; ul < ulSize; ul++) { CColRefSet *pcrs = GPOS_NEW(pmp) CColRefSet(pmp, (*m_pdrgpdrgpcrInput)[ul]); pdrgpcrsOutput->Append(pcrs); } IStatistics *pstatsOuter = exprhdl.Pstats(0); IStatistics *pstatsInner = exprhdl.Pstats(1); // construct the scalar condition for the LASJ CExpression *pexprScCond = CUtils::PexprConjINDFCond(pmp, m_pdrgpdrgpcrInput); // compute the statistics for LASJ CColRefSet *pcrsOuterRefs = exprhdl.Pdprel()->PcrsOuter(); DrgPstatsjoin *pdrgpstatsjoin = CStatsPredUtils::Pdrgpstatsjoin ( pmp, exprhdl, pexprScCond, pdrgpcrsOutput, pcrsOuterRefs ); IStatistics *pstatsLASJ = pstatsOuter->PstatsLASJoin ( pmp, pstatsInner, pdrgpstatsjoin, true /* fIgnoreLasjHistComputation*/ ); // clean up pexprScCond->Release(); pdrgpstatsjoin->Release(); pdrgpcrsOutput->Release(); return pstatsLASJ; }
//--------------------------------------------------------------------------- // @function: // CLogicalDifference::PstatsDerive // // @doc: // Derive statistics // //--------------------------------------------------------------------------- IStatistics * CLogicalDifference::PstatsDerive ( IMemoryPool *pmp, CExpressionHandle &exprhdl, DrgPstat * // not used ) const { GPOS_ASSERT(Esp(exprhdl) > EspNone); // difference is transformed into an aggregate over a LASJ, // we follow the same route to compute statistics DrgPcrs *pdrgpcrsOutput = GPOS_NEW(pmp) DrgPcrs(pmp); const ULONG ulSize = m_pdrgpdrgpcrInput->UlLength(); for (ULONG ul = 0; ul < ulSize; ul++) { CColRefSet *pcrs = GPOS_NEW(pmp) CColRefSet(pmp, (*m_pdrgpdrgpcrInput)[ul]); pdrgpcrsOutput->Append(pcrs); } IStatistics *pstatsOuter = exprhdl.Pstats(0); IStatistics *pstatsInner = exprhdl.Pstats(1); // construct the scalar condition for the LASJ CExpression *pexprScCond = CUtils::PexprConjINDFCond(pmp, m_pdrgpdrgpcrInput); // compute the statistics for LASJ CColRefSet *pcrsOuterRefs = exprhdl.Pdprel()->PcrsOuter(); DrgPstatsjoin *pdrgpstatsjoin = CStatsPredUtils::Pdrgpstatsjoin ( pmp, exprhdl, pexprScCond, pdrgpcrsOutput, pcrsOuterRefs ); IStatistics *pstatsLASJ = pstatsOuter->PstatsLASJoin ( pmp, pstatsInner, pdrgpstatsjoin, true /* fIgnoreLasjHistComputation */ ); // clean up pexprScCond->Release(); pdrgpstatsjoin->Release(); // computed columns DrgPul *pdrgpulComputedCols = GPOS_NEW(pmp) DrgPul(pmp); IStatistics *pstats = CLogicalGbAgg::PstatsDerive ( pmp, pstatsLASJ, (*m_pdrgpdrgpcrInput)[0], // we group by the columns of the first child pdrgpulComputedCols, // no computed columns for set ops NULL // no keys, use all grouping cols ); // clean up pdrgpulComputedCols->Release(); pstatsLASJ->Release(); pdrgpcrsOutput->Release(); return pstats; }