Skip to content

Commit

Permalink
Merge pull request #45058 from nextcloud/perf/db/sort-before-chunking
Browse files Browse the repository at this point in the history
perf(db): Sort data for IN before chunking
  • Loading branch information
ChristophWurst authored May 7, 2024
2 parents 0af06f6 + f3d6309 commit 6258823
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 6258823

Please sign in to comment.