[
https://issues.apache.org/jira/browse/TRAFODION-1562?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15858761#comment-15858761
]
ASF GitHub Bot commented on TRAFODION-1562:
-------------------------------------------
Github user zellerh commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/946#discussion_r100204780
--- Diff: core/sql/optimizer/BindRelExpr.cpp ---
@@ -10600,34 +10600,45 @@ Upsert is also converted into merge when
TRAF_UPSERT_MODE is set to MERGE and
there are omitted cols with default values in case of aligned format table
or
omitted current timestamp cols in case of non-aligned row format
*/
-NABoolean Insert::isUpsertThatNeedsMerge(NABoolean isAlignedRowFormat,
NABoolean omittedDefaultCols,
- NABoolean
omittedCurrentDefaultClassCols) const
+NABoolean Insert::isUpsertThatNeedsTransformation(NABoolean
isAlignedRowFormat,
+ NABoolean
omittedDefaultCols,
+ NABoolean
omittedCurrentDefaultClassCols,
+ NABoolean &toMerge) const
{
- // The necessary conditions to convert upsert to merge and
+ // The necessary conditions to transform upsert
if (isUpsert() &&
(NOT getIsTrafLoadPrep()) &&
- (NOT (getTableDesc()->isIdentityColumnGeneratedAlways() &&
getTableDesc()->hasIdentityColumnInClusteringKey())) &&
+ (NOT (getTableDesc()->isIdentityColumnGeneratedAlways() &&
+ getTableDesc()->hasIdentityColumnInClusteringKey())) &&
(NOT
(getTableDesc()->getClusteringIndex()->getNAFileSet()->hasSyskey())) &&
- // table has secondary indexes or
- (getTableDesc()->hasSecondaryIndexes() ||
- // CQD is set to MERGE
- ((CmpCommon::getDefault(TRAF_UPSERT_MODE) == DF_MERGE) &&
+ // 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)
||
--- End diff --
Maybe another short comment here that TRAF_UPSERT_MERGE controls the
behavior of upserting an existing row with a subset of columns. ON means keep
the column values of the existing row for the omitted columns (slower) and OFF
means setting the omitted columns to default values (faster). Since there is no
standard for UPSERT, either behavior could be considered "correct".
> 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)