Skip to content

Commit

Permalink
fix: use initial shard encoded in primary key as most likely shard
Browse files Browse the repository at this point in the history
Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Aug 20, 2024
1 parent 626d659 commit 4950a4b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/private/DB/QueryBuilder/Sharded/ShardQueryRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,20 @@ public function getShards(bool $allShards, array $shardKeys): ?array {
}

/**
* Try to get the shards that the keys are likely to be in, based on the shard the row was created on and caching
* Try to get the shards that the keys are likely to be in, based on the shard the row was created
*
* @param int[] $primaryKeys
* @return int[]
*/
private function getLikelyShards(array $primaryKeys): array {
// todo
return [];
$shards = [];
foreach ($primaryKeys as $primaryKey) {
$encodedShard = $primaryKey & ShardDefinition::PRIMARY_KEY_SHARD_MASK;
if (!in_array($encodedShard, $shards)) {
$shards[] = $encodedShard;
}
}
return $shards;
}

/**
Expand Down

0 comments on commit 4950a4b

Please sign in to comment.