aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/executor')
-rw-r--r--src/backend/executor/execIndexing.c37
-rw-r--r--src/backend/executor/execReplication.c9
-rw-r--r--src/backend/executor/nodeModifyTable.c13
3 files changed, 40 insertions, 19 deletions
diff --git a/src/backend/executor/execIndexing.c b/src/backend/executor/execIndexing.c
index 6e88e72813f..da28e5e40ca 100644
--- a/src/backend/executor/execIndexing.c
+++ b/src/backend/executor/execIndexing.c
@@ -259,15 +259,24 @@ ExecCloseIndices(ResultRelInfo *resultRelInfo)
* into all the relations indexing the result relation
* when a heap tuple is inserted into the result relation.
*
- * When 'update' is true, executor is performing an UPDATE
- * that could not use an optimization like heapam's HOT (in
- * more general terms a call to table_tuple_update() took
- * place and set 'update_indexes' to true). Receiving this
- * hint makes us consider if we should pass down the
- * 'indexUnchanged' hint in turn. That's something that we
- * figure out for each index_insert() call iff 'update' is
- * true. (When 'update' is false we already know not to pass
- * the hint to any index.)
+ * When 'update' is true and 'onlySummarizing' is false,
+ * executor is performing an UPDATE that could not use an
+ * optimization like heapam's HOT (in more general terms a
+ * call to table_tuple_update() took place and set
+ * 'update_indexes' to TUUI_All). Receiving this hint makes
+ * us consider if we should pass down the 'indexUnchanged'
+ * hint in turn. That's something that we figure out for
+ * each index_insert() call iff 'update' is true.
+ * (When 'update' is false we already know not to pass the
+ * hint to any index.)
+ *
+ * If onlySummarizing is set, an equivalent optimization to
+ * HOT has been applied and any updated columns are indexed
+ * only by summarizing indexes (or in more general terms a
+ * call to table_tuple_update() took place and set
+ * 'update_indexes' to TUUI_Summarizing). We can (and must)
+ * therefore only update the indexes that have
+ * 'amsummarizing' = true.
*
* Unique and exclusion constraints are enforced at the same
* time. This returns a list of index OIDs for any unique or
@@ -287,7 +296,8 @@ ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
bool update,
bool noDupErr,
bool *specConflict,
- List *arbiterIndexes)
+ List *arbiterIndexes,
+ bool onlySummarizing)
{
ItemPointer tupleid = &slot->tts_tid;
List *result = NIL;
@@ -343,6 +353,13 @@ ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
if (!indexInfo->ii_ReadyForInserts)
continue;
+ /*
+ * Skip processing of non-summarizing indexes if we only
+ * update summarizing indexes
+ */
+ if (onlySummarizing && !indexInfo->ii_Summarizing)
+ continue;
+
/* Check for partial index */
if (indexInfo->ii_Predicate != NIL)
{
diff --git a/src/backend/executor/execReplication.c b/src/backend/executor/execReplication.c
index fa8628e3e1b..c4bc69f1e55 100644
--- a/src/backend/executor/execReplication.c
+++ b/src/backend/executor/execReplication.c
@@ -491,7 +491,7 @@ ExecSimpleRelationInsert(ResultRelInfo *resultRelInfo,
if (resultRelInfo->ri_NumIndices > 0)
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
slot, estate, false, false,
- NULL, NIL);
+ NULL, NIL, false);
/* AFTER ROW INSERT Triggers */
ExecARInsertTriggers(estate, resultRelInfo, slot,
@@ -539,7 +539,7 @@ ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo,
if (!skip_tuple)
{
List *recheckIndexes = NIL;
- bool update_indexes;
+ TU_UpdateIndexes update_indexes;
/* Compute stored generated columns */
if (rel->rd_att->constr &&
@@ -556,10 +556,11 @@ ExecSimpleRelationUpdate(ResultRelInfo *resultRelInfo,
simple_table_tuple_update(rel, tid, slot, estate->es_snapshot,
&update_indexes);
- if (resultRelInfo->ri_NumIndices > 0 && update_indexes)
+ if (resultRelInfo->ri_NumIndices > 0 && (update_indexes != TU_None))
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
slot, estate, true, false,
- NULL, NIL);
+ NULL, NIL,
+ (update_indexes == TU_Summarizing));
/* AFTER ROW UPDATE Triggers */
ExecARUpdateTriggers(estate, resultRelInfo,
diff --git a/src/backend/executor/nodeModifyTable.c b/src/backend/executor/nodeModifyTable.c
index 3fa2b930a52..3a673895082 100644
--- a/src/backend/executor/nodeModifyTable.c
+++ b/src/backend/executor/nodeModifyTable.c
@@ -110,8 +110,8 @@ typedef struct ModifyTableContext
typedef struct UpdateContext
{
bool updated; /* did UPDATE actually occur? */
- bool updateIndexes; /* index update required? */
bool crossPartUpdate; /* was it a cross-partition update? */
+ TU_UpdateIndexes updateIndexes; /* Which index updates are required? */
/*
* Lock mode to acquire on the latest tuple version before performing
@@ -1099,7 +1099,8 @@ ExecInsert(ModifyTableContext *context,
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
slot, estate, false, true,
&specConflict,
- arbiterIndexes);
+ arbiterIndexes,
+ false);
/* adjust the tuple's state accordingly */
table_tuple_complete_speculative(resultRelationDesc, slot,
@@ -1138,7 +1139,8 @@ ExecInsert(ModifyTableContext *context,
if (resultRelInfo->ri_NumIndices > 0)
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
slot, estate, false,
- false, NULL, NIL);
+ false, NULL, NIL,
+ false);
}
}
@@ -2118,11 +2120,12 @@ ExecUpdateEpilogue(ModifyTableContext *context, UpdateContext *updateCxt,
List *recheckIndexes = NIL;
/* insert index entries for tuple if necessary */
- if (resultRelInfo->ri_NumIndices > 0 && updateCxt->updateIndexes)
+ if (resultRelInfo->ri_NumIndices > 0 && (updateCxt->updateIndexes != TU_None))
recheckIndexes = ExecInsertIndexTuples(resultRelInfo,
slot, context->estate,
true, false,
- NULL, NIL);
+ NULL, NIL,
+ (updateCxt->updateIndexes == TU_Summarizing));
/* AFTER ROW UPDATE Triggers */
ExecARUpdateTriggers(context->estate, resultRelInfo,