Skip to content

Commit 6258823

Browse files
Merge pull request #45058 from nextcloud/perf/db/sort-before-chunking
perf(db): Sort data for IN before chunking
2 parents 0af06f6 + f3d6309 commit 6258823

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/private/Files/Cache/Cache.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,9 @@ private function removeChildren(ICacheEntry $entry) {
620620
$query->delete('filecache')
621621
->whereParentInParameter('parentIds');
622622

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

0 commit comments

Comments
 (0)