Github user zellerh commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/1051#discussion_r111432560
--- Diff: core/sql/optimizer/RelExpr.cpp ---
@@ -9055,19 +9056,33 @@ void Scan::setTableAttributes(CANodeId nodeId)
setBaseCardinality(MIN_ONE (tableDesc->getNATable()->getEstRowCount())) ;
}
-NABoolean Scan::updateableIndex(IndexDesc *idx)
+NABoolean Scan::updateableIndex(IndexDesc *idx, ValueIdSet& preds,
+ NABoolean & needsHalloweenProtection)
{
//
- // Returns TRUE if the index (idx) can be used for a scan during
- // an UPDATE. Halloween problem is protected with a sort using
- // Scan::requiresHalloweenForUpdateUsingIndexScan().
- // Returns FALSE only for certain embedded updates now.
+ // Returns TRUE if the index (idx) can be used for a scan during an
UPDATE.
+ // Returns TRUE with needsHalloweenProtection also set to TRUE, if the
index
+ // needs a blocking sort for Halloween protection
+ // Otherwise, returns FALSE to prevent use of this index.
+ // Using the index in this case requires Halloween protection, but is
likely
+ // inefficient since there are no useful preds on the index key columns,
so
+ // we don't add this index to list of candidates.
//
- if (!getGroupAttr()->isEmbeddedUpdate())
- return TRUE ;
-
+ // The conditions of when this index returns TRUE can also be expressed
as
+ // returns true for an index if it is
+ // a) a unique/clustering index or
+ // b) has a unique predicate on its key or
+ // c) has an equals or range predicate on all the index columns that
--- End diff --
Just updated the comment above to simplify the condition for when we need
Halloween protection. Checking for a unique key on _ixcols_ is not needed, all
we have to check are equality predicates on the updated columns.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---