Skip to content

Commit

Permalink
perf(db): Sort data for IN before chunking
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <[email protected]>
  • Loading branch information
ChristophWurst committed Apr 26, 2024
1 parent 10af087 commit f3d6309
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,9 @@ private function removeChildren(ICacheEntry $entry) {
$query->delete('filecache')
->whereParentInParameter('parentIds');

// Sorting before chunking allows the db to find the entries close to each
// other in the index
sort($parentIds, SORT_NUMERIC);
foreach (array_chunk($parentIds, 1000) as $parentIdChunk) {
$query->setParameter('parentIds', $parentIdChunk, IQueryBuilder::PARAM_INT_ARRAY);
$query->execute();
Expand Down

0 comments on commit f3d6309

Please sign in to comment.