Skip to content

Commit

Permalink
Merge pull request #45215 from nextcloud/backport/45058/stable29
Browse files Browse the repository at this point in the history
[stable29] perf(db): Sort data for IN before chunking
  • Loading branch information
joshtrichards authored May 28, 2024
2 parents 2a61d2b + 9c4d8b3 commit 413526a
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 413526a

Please sign in to comment.