Move PushActiveSnapshot outside a for loop (#8253)

In the PR [8142](https://github.com/citusdata/citus/pull/8142) was added
`PushActiveSnapshot`.

This commit places it outside a for loop as taking a snapshot is a resource
heavy operation.
colm/pg18-8276
Ivan Kush 2025-10-31 21:20:12 +03:00 committed by Colm McHugh
parent ba540ef7fb
commit d681bbacfd
1 changed files with 10 additions and 2 deletions

View File

@ -618,7 +618,13 @@ SaveStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
Oid columnarChunkOid = ColumnarChunkRelationId();
Relation columnarChunk = table_open(columnarChunkOid, RowExclusiveLock);
ModifyState *modifyState = StartModifyRelation(columnarChunk);
bool pushed_snapshot = false;
if (!ActiveSnapshotSet())
{
PushActiveSnapshot(GetTransactionSnapshot());
pushed_snapshot = true;
}
for (columnIndex = 0; columnIndex < columnCount; columnIndex++)
{
for (chunkIndex = 0; chunkIndex < chunkList->chunkCount; chunkIndex++)
@ -659,11 +665,13 @@ SaveStripeSkipList(RelFileLocator relfilelocator, uint64 stripe,
nulls[Anum_columnar_chunk_minimum_value - 1] = true;
nulls[Anum_columnar_chunk_maximum_value - 1] = true;
}
PushActiveSnapshot(GetTransactionSnapshot());
InsertTupleAndEnforceConstraints(modifyState, values, nulls);
PopActiveSnapshot();
}
}
if (pushed_snapshot)
{
PopActiveSnapshot();
}
FinishModifyRelation(modifyState);
table_close(columnarChunk, RowExclusiveLock);