]> source.dussan.org Git - nextcloud-server.git/commitdiff
perf(db): Sort data for IN before chunking 45215/head
authorChristoph Wurst <christoph@winzerhof-wurst.at>
Fri, 26 Apr 2024 13:38:29 +0000 (15:38 +0200)
committerJosh <josh.t.richards@gmail.com>
Sun, 26 May 2024 00:48:55 +0000 (20:48 -0400)
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
lib/private/Files/Cache/Cache.php

index 8f0f962a3b7717a85b489fea3d1fb19f8d5d6079..053856afa4f6f795d78b7b12fb1da895c4b2ca05 100644 (file)
@@ -620,6 +620,9 @@ class Cache implements ICache {
                $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();