[ 
https://issues.apache.org/jira/browse/TRAFODION-25?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14720058#comment-14720058
 ] 

ASF GitHub Bot commented on TRAFODION-25:
-----------------------------------------

Github user nonstop-qfchen commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/68#discussion_r38215039
  
    --- Diff: core/sql/optimizer/costmethod.cpp ---
    @@ -13997,15 +13997,188 @@ 
CostMethodFastExtract::computeOperatorCostInternal(RelExpr* op,
     /**********************************************************************/
     
     //<pb>
    -// ----QUICKSEARCH FOR DP2Insert........................................
    +// ----QUICKSEARCH FOR HbaseInsert........................................
     
     /**********************************************************************/
     /*                                                                    */
    -/*                      CostMethodDP2Insert                           */
    +/*                      CostMethodHbaseInsert                         */
     /*                                                                    */
     /**********************************************************************/
     
    -#pragma nowarn(262)   // warning elimination
    +// -----------------------------------------------------------------------
    +// CostMethodHbaseInsert::cacheParameters()
    +// -----------------------------------------------------------------------
    +void CostMethodHbaseInsert::cacheParameters(RelExpr* op, const Context * 
myContext)
    +{
    +  CostMethod::cacheParameters(op, myContext);
    +
    +  HbaseInsert* insOp = (HbaseInsert *)op;
    +
    +  CMPASSERT(partFunc_ != NULL);
    +  NodeMap * nodeMap = (NodeMap *)partFunc_->getNodeMap();
    +  if (nodeMap)
    +    activePartitions_ = (CostScalar)nodeMap->getNumActivePartitions();
    +  else
    +    // Occasionally (e.g., regress/fullstack2/test023, the insert/select
    +    // from t023t1 into t023t2 using a transpose operator), we get
    +    // a ReplicateNoBroadcastPartitioningFunction lacking a node map.
    +    // In this case we'll just use the number of partitions from the
    +    // partitioning function itself -- which is probably an ESP count.
    +    activePartitions_ = (CostScalar)partFunc_->getCountOfPartitions();
    +
    +  // The number of asynchronous streams is USUALLY the # of active parts.
    +  countOfAsynchronousStreams_ = activePartitions_;
    +} // CostMethodHbaseInsert::cacheParameters()
    +
    +
    +
    +// -----------------------------------------------------------------------
    +// CostMethodHbaseInsert::computeOperatorCostInternal()
    +// -----------------------------------------------------------------------
    +Cost* CostMethodHbaseInsert::computeOperatorCostInternal(RelExpr* op,
    +  const Context* myContext,
    +  Lng32& countOfStreams)
    +{
    +  cacheParameters(op, myContext);
    +  estimateDegreeOfParallelism();
    +
    +  // ------------------------------------------------------
    +  // Save off our current estimated degree of parallelism.
    +  // in the 'out' parameter; we might revise it below
    +  // ------------------------------------------------------
    +  countOfStreams = countOfStreams_;
    +
    +  CostScalar currentCpus =
    +    
(CostScalar)myContext->getPlan()->getPhysicalProperty()->getCurrentCountOfCPUs();
    +  activeCpus_ = MINOF(countOfAsynchronousStreams_, currentCpus);
    +
    +  // update count of streams; the caller of the method uses this value
    +  if ((countOfAsynchronousStreams_ > 0) &&
    +      (countOfAsynchronousStreams_ < countOfStreams)
    +      )
    +    countOfStreams = (Lng32)countOfAsynchronousStreams_.getValue();
    +
    +
    +  streamsPerCpu_ =
    +    (countOfAsynchronousStreams_ / activeCpus_).getCeiling();
    +
    +  CostScalar noOfProbesPerStream(csOne);
    +
    +  // Determine the number of probes per stream. Use this number as
    +  // the number of rows to insert (this is "per-stream" costing).
    +
    +  noOfProbesPerStream =
    +    (noOfProbes_ / countOfAsynchronousStreams_).minCsOne();
    +
    +  // ************************************************************
    +  // Compute the write/read cost for the insert
    --- End diff --
    
    is there a read cost for insert?


> Insert, delete and update operators should use specialized cost method 
> -----------------------------------------------------------------------
>
>                 Key: TRAFODION-25
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-25
>             Project: Apache Trafodion
>          Issue Type: Bug
>            Reporter: Qifan Chen
>            Assignee: David Wayne Birdsall
>              Labels: performance
>
> In Trafodion, insert, delete and update operators do not use a specialized 
> cost method that model the true operation involved. 
> As a result, these operators can be assigned a zero cost and the query plan 
> may not be optimal. In one example, a delete query against a partitioned 
> table may get a serial plan. 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to