[performance improvement] remove duplicate LoadShardList call (#7380)

LoadShardList is called twice, which is not neccessary, and there is no
need to sort the shard placement list since we only want to know the list
length.
pull/7377/head^2
zhjwpku 2024-01-10 18:15:19 +08:00 committed by GitHub
parent 1d55debb98
commit 8e979f7ac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 8 deletions

View File

@ -381,7 +381,7 @@ EnsureModificationsCanRun(void)
/* /*
* EnsureModificationsCanRunOnRelation firsts calls into EnsureModificationsCanRun() and * EnsureModificationsCanRunOnRelation first calls into EnsureModificationsCanRun() and
* then does one more additional check. The additional check is to give a proper error * then does one more additional check. The additional check is to give a proper error
* message if any relation that is modified is replicated, as replicated tables use * message if any relation that is modified is replicated, as replicated tables use
* 2PC and 2PC cannot happen when recovery is in progress. * 2PC and 2PC cannot happen when recovery is in progress.

View File

@ -362,10 +362,8 @@ ErrorIfShardPlacementsNotColocated(Oid leftRelationId, Oid rightRelationId)
leftRelationName, rightRelationName))); leftRelationName, rightRelationName)));
} }
List *leftPlacementList = ShardPlacementListSortedByWorker( List *leftPlacementList = ShardPlacementList(leftShardId);
leftShardId); List *rightPlacementList = ShardPlacementList(rightShardId);
List *rightPlacementList = ShardPlacementListSortedByWorker(
rightShardId);
if (list_length(leftPlacementList) != list_length(rightPlacementList)) if (list_length(leftPlacementList) != list_length(rightPlacementList))
{ {

View File

@ -470,12 +470,11 @@ SingleReplicatedTable(Oid relationId)
return false; return false;
} }
List *shardIntervalList = LoadShardList(relationId);
uint64 *shardIdPointer = NULL; uint64 *shardIdPointer = NULL;
foreach_ptr(shardIdPointer, shardIntervalList) foreach_ptr(shardIdPointer, shardList)
{ {
uint64 shardId = *shardIdPointer; uint64 shardId = *shardIdPointer;
shardPlacementList = ShardPlacementListSortedByWorker(shardId); shardPlacementList = ShardPlacementList(shardId);
if (list_length(shardPlacementList) != 1) if (list_length(shardPlacementList) != 1)
{ {