trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zellerh <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #1051: [TRAAFODION-2568] [TRAFODION-2574]
Date Mon, 10 Apr 2017 18:55:43 GMT
Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/1051#discussion_r110727742
  
    --- Diff: core/sql/optimizer/RelExpr.cpp ---
    @@ -9121,38 +9090,85 @@ NABoolean Scan::updateableIndex(IndexDesc *idx)
       {
         ItemExpr *updateCol = colUpdated[i].getItemExpr();
         CMPASSERT(updateCol->getOperatorType() == ITM_BASECOLUMN);
    -
         for (CollIndex j = 0; j < indexKey.entries(); j++)
         {
           ItemExpr *keyCol = indexKey[j].getItemExpr();
    -
    -      ItemExpr *baseCol = ((IndexColumn*)keyCol)->getDefinition().getItemExpr();
    +      ItemExpr *baseCol = 
    +        ((IndexColumn*)keyCol)->getDefinition().getItemExpr();
           CMPASSERT(baseCol->getOperatorType() == ITM_BASECOLUMN);
    -
    -      // QSTUFF
    -      if (getGroupAttr()->isEmbeddedUpdate()){
    -        if (((BaseColumn*)updateCol)->getColNumber() ==
    +      if (((BaseColumn*)updateCol)->getColNumber() ==
               ((BaseColumn*)baseCol)->getColNumber())
    -          return FALSE;
    -      }
    -      // QSTUFF
    +        return FALSE;
    +    }
    +  }
    +  return TRUE;
    +} // Scan::updateableIndex
    +
    +NABoolean Scan::requiresHalloweenForUpdateUsingIndexScan()
    +{
    +
    +  // Returns TRUE if any non clustering index can be used for a scan 
    +  // during an UPDATE and a key column of that index is in the SET
    +  // clause of the update. If this method returns TRUE we will use a 
    +  // sort node to prevent the "Halloween Update Problem".
    +  //
     
    -      if ((NOT(idx->isUniqueIndex() || idx->isClusteringIndex()))
    -	     ||
    -	  (CmpCommon::getDefault(UPDATE_CLUSTERING_OR_UNIQUE_INDEX_KEY) == DF_OFF))
    +  // preds are in RangeSpec form
    +  ValueIdSet preds = getSelectionPredicates();
    +  const ValueIdList colUpdated = getTableDesc()->getColUpdated();
    +  const LIST(IndexDesc *) & ixlist = getTableDesc()->getIndexes();
    +
    +  if ((colUpdated.entries() == 0) || (preds.entries() == 0) ||
    +      (ixlist.entries() == 1) || // this is the clustering index
    +      (CmpCommon::getDefault(UPDATE_CLUSTERING_OR_UNIQUE_INDEX_KEY) 
    +       == DF_AGGRESSIVE)) // this setting means no Halloween protection
    +    return FALSE;
    +
    +   if (CmpCommon::getDefault(RANGESPEC_TRANSFORMATION) == DF_ON)
    +   {
    +     ValueIdList selectionPredList(preds);
    +     ItemExpr *inputItemExprTree = 
    +       selectionPredList.rebuildExprTree(ITM_AND,FALSE,FALSE);
    +     ItemExpr * resultOld = revertBackToOldTree(STMTHEAP, 
    +                                                inputItemExprTree);
    +     preds.clear();
    +     resultOld->convertToValueIdSet(preds, NULL, ITM_AND);
    +     doNotReplaceAnItemExpressionForLikePredicates(resultOld,preds,
    +                                                   resultOld);
    +   }
     
    +  for (CollIndex indexNo = 0; indexNo < ixlist.entries(); indexNo++)
    +  {
    +    IndexDesc *idx = ixlist[indexNo];
    +    if (idx->isClusteringIndex() || 
    +        (idx->isUniqueIndex() && 
    +        (CmpCommon::getDefault(UPDATE_CLUSTERING_OR_UNIQUE_INDEX_KEY) 
    +         == DF_ON)))
    +      continue ; // skip this idesc
    +
    +    const ValueIdList indexKey = idx->getIndexKey();
    --- End diff --
    
    Could save a few nanoseconds here by not making a copy of the key and using a reference.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message