Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5ac2b3d

Browse files
michail-nikolaevCommitfest Bot
authored and
Commitfest Bot
committed
Optimize auxiliary index handling
Skip unnecessary computations for auxiliary indices by: - in the index‐insert path, detect auxiliary indexes and bypass Datum value computation - set indexUnchanged=false for auxiliary indices to avoid redundant checks These optimizations reduce overhead during concurrent index operations.
1 parent 2ee9022 commit 5ac2b3d

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/backend/catalog/index.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2932,6 +2932,17 @@ FormIndexDatum(IndexInfo *indexInfo,
29322932
ListCell *indexpr_item;
29332933
int i;
29342934

2935+
/* Auxiliary index does not need any values to be computed */
2936+
if (unlikely(indexInfo->ii_Auxiliary))
2937+
{
2938+
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
2939+
{
2940+
values[i] = PointerGetDatum(NULL);
2941+
isnull[i] = true;
2942+
}
2943+
return;
2944+
}
2945+
29352946
if (indexInfo->ii_Expressions != NIL &&
29362947
indexInfo->ii_ExpressionsState == NIL)
29372948
{

src/backend/executor/execIndexing.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,14 @@ ExecInsertIndexTuples(ResultRelInfo *resultRelInfo,
440440
* There's definitely going to be an index_insert() call for this
441441
* index. If we're being called as part of an UPDATE statement,
442442
* consider if the 'indexUnchanged' = true hint should be passed.
443+
*
444+
* In case of auxiliary index always pass false as optimisation.
443445
*/
444-
indexUnchanged = update && index_unchanged_by_update(resultRelInfo,
445-
estate,
446-
indexInfo,
447-
indexRelation);
446+
indexUnchanged = update && likely(!indexInfo->ii_Auxiliary) &&
447+
index_unchanged_by_update(resultRelInfo,
448+
estate,
449+
indexInfo,
450+
indexRelation);
448451

449452
satisfiesConstraint =
450453
index_insert(indexRelation, /* index relation */

0 commit comments

Comments
 (0)