Skip to content

Commit

Permalink
[performance improvement] remove duplicate LoadShardList call (#7380)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
zhjwpku authored Jan 10, 2024
1 parent 1d55deb commit 8e979f7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/backend/distributed/metadata/metadata_cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
* message if any relation that is modified is replicated, as replicated tables use
* 2PC and 2PC cannot happen when recovery is in progress.
Expand Down
6 changes: 2 additions & 4 deletions src/backend/distributed/utils/colocation_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,8 @@ ErrorIfShardPlacementsNotColocated(Oid leftRelationId, Oid rightRelationId)
leftRelationName, rightRelationName)));
}

List *leftPlacementList = ShardPlacementListSortedByWorker(
leftShardId);
List *rightPlacementList = ShardPlacementListSortedByWorker(
rightShardId);
List *leftPlacementList = ShardPlacementList(leftShardId);
List *rightPlacementList = ShardPlacementList(rightShardId);

if (list_length(leftPlacementList) != list_length(rightPlacementList))
{
Expand Down
5 changes: 2 additions & 3 deletions src/backend/distributed/utils/shardinterval_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,11 @@ SingleReplicatedTable(Oid relationId)
return false;
}

List *shardIntervalList = LoadShardList(relationId);
uint64 *shardIdPointer = NULL;
foreach_ptr(shardIdPointer, shardIntervalList)
foreach_ptr(shardIdPointer, shardList)
{
uint64 shardId = *shardIdPointer;
shardPlacementList = ShardPlacementListSortedByWorker(shardId);
shardPlacementList = ShardPlacementList(shardId);

if (list_length(shardPlacementList) != 1)
{
Expand Down

0 comments on commit 8e979f7

Please sign in to comment.