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

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

Github user sureshsubbiah commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/946#discussion_r100641201
  
    --- Diff: core/sql/optimizer/BindRelExpr.cpp ---
    @@ -10605,43 +10605,62 @@ NABoolean 
Insert::isUpsertThatNeedsTransformation(NABoolean isAlignedRowFormat,
                                                       NABoolean 
omittedCurrentDefaultClassCols,
                                                       NABoolean &toMerge) const
     {
    -  // The necessary conditions to transform upsert 
    +  toMerge = FALSE;
    +  // If the the table has an identity column in clustering key or has a 
syskey 
    +  // we dont need to do this transformation.The incoming row will always 
be 
    +  // unique. So first check if we any of the conditions are satisfied to 
    +  //even try the transform
    +  NABoolean mustTryTransform = FALSE;
       if (isUpsert() && 
    -      (NOT getIsTrafLoadPrep()) && 
    +      ( NOT getIsTrafLoadPrep()) &&
           (NOT (getTableDesc()->isIdentityColumnGeneratedAlways() && 
    -            getTableDesc()->hasIdentityColumnInClusteringKey())) && 
    -      (NOT 
(getTableDesc()->getClusteringIndex()->getNAFileSet()->hasSyskey())) && 
    -      // table has secondary indexes or
    -      (getTableDesc()->hasSecondaryIndexes() ))
    -        {
    -          toMerge = FALSE;
    -          return TRUE;
    -        }
    -  else if (isUpsert() &&   (NOT getIsTrafLoadPrep()) && 
    -           (NOT (getTableDesc()->isIdentityColumnGeneratedAlways() && 
getTableDesc()->hasIdentityColumnInClusteringKey())) && 
    -           (NOT 
(getTableDesc()->getClusteringIndex()->getNAFileSet()->hasSyskey())) &&         
    -           // CQD is set to MERGE  
    -           ((CmpCommon::getDefault(TRAF_UPSERT_MODE) == DF_MERGE) &&
    -            // omitted current default columns with non-aligned row format 
tables
    -            // or omitted default columns with aligned row format tables 
    -            (((NOT isAlignedRowFormat) && omittedCurrentDefaultClassCols) 
||
    -            (isAlignedRowFormat && omittedDefaultCols))) ||
    -           // CQD is set to Optimal, for non-aligned row format with 
omitted 
    -           // current columns, it is converted into merge though it is not
    -           // optimal for performance - This is done to ensure that when 
the 
    -           // CQD is set to optimal, non-aligned format would behave like 
    -           // merge when any column is  omitted 
    -           ((CmpCommon::getDefault(TRAF_UPSERT_MODE) == DF_OPTIMAL) &&
    -            ((NOT isAlignedRowFormat) && omittedCurrentDefaultClassCols)))
    +            getTableDesc()->hasIdentityColumnInClusteringKey()))  && 
    +      
(NOT(getTableDesc()->getClusteringIndex()->getNAFileSet()->hasSyskey())))
    +    {
    +      mustTryTransform = TRUE;
    +    }
    +
    +  // Transform upsert to merge in case of special modes and
    +  // omitted default columns
    +  // Case 1 :  CQD is set to MERGE, omitted current(timestamp) default 
    +  //           columns with  non-aligned row format table or omitted 
    +  //           default columns with aligned row format tables 
    +
    +  // Case 2 :  CQD is set to Optimal, for non-aligned row format with 
omitted 
    +  //           current(timestamp) columns, it is converted into merge 
    +  //           though it is not optimal for performance. This is done to 
ensure
    +  //           that when the CQD is set to optimal, non-aligned format 
would 
    +  //           behave like merge when any column is  omitted 
    +  if (isUpsert()  &&   
    +      mustTryTransform &&          
    +      ((CmpCommon::getDefault(TRAF_UPSERT_MODE) == DF_MERGE) &&     
    +       (((NOT isAlignedRowFormat) && omittedCurrentDefaultClassCols) ||
    +        (isAlignedRowFormat && omittedDefaultCols)))
    +      ||
    +      ((CmpCommon::getDefault(TRAF_UPSERT_MODE) == DF_OPTIMAL) &&
    +       ((NOT isAlignedRowFormat) && omittedCurrentDefaultClassCols)))
         {
           toMerge = TRUE;
           return TRUE;
         }
    -  toMerge = FALSE;
    +
    +  // Transform upsert to efficient tree if none of the above conditions 
    +  // are true and the table has secondary indexes 
    +  if (isUpsert() &&  
    +      mustTryTransform &&
    +      (getTableDesc()->hasSecondaryIndexes()))
    +    {
    +      toMerge = FALSE;
    +      return TRUE;
    +    }
    +  
    --- End diff --
    
    Looks good @sandhyasun. All my concerns have been addressed in the best 
possible manner. Thanks.+1


> Changes in query tree when the upsert command is transformed into merge
> -----------------------------------------------------------------------
>
>                 Key: TRAFODION-1562
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-1562
>             Project: Apache Trafodion
>          Issue Type: Sub-task
>          Components: sql-cmp
>            Reporter: Selvaganesan Govindarajan
>            Assignee: Sandhya Sundaresan
>         Attachments: BatchUpsertTransformation.pdf
>
>
> to improve the performance as explained in the main JIRA



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Reply via email to