Skip to content

Commit 8d2502a

Browse files
Merge pull request #45214 from nextcloud/backport/45058/stable28
[stable28] perf(db): Sort data for IN before chunking
2 parents f0902db + 66898f8 commit 8d2502a

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
@@ -623,6 +623,9 @@ private function removeChildren(ICacheEntry $entry) {
623623
$query->delete('filecache')
624624
->whereParentInParameter('parentIds');
625625

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

0 commit comments

Comments
 (0)