From: Christoph Wurst Date: Fri, 26 Apr 2024 13:38:29 +0000 (+0200) Subject: perf(db): Sort data for IN before chunking X-Git-Tag: v29.0.2rc1~7^2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=refs%2Fpull%2F45215%2Fhead;p=nextcloud-server.git perf(db): Sort data for IN before chunking Signed-off-by: Christoph Wurst --- diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index 8f0f962a3b7..053856afa4f 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -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();