summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh <josh.t.richards@gmail.com>2024-05-28 17:04:56 -0400
committerGitHub <noreply@github.com>2024-05-28 17:04:56 -0400
commit413526a688287ae466b617e0190c17286a1954be (patch)
treeff87ea8e52d604ac5dd9b301225d79fedd8f5d24
parent2a61d2bcdb73c37523d7ec674b99f4837dfe7803 (diff)
parent9c4d8b3337146e9f35e0b7f110bef9d059236f8b (diff)
downloadnextcloud-server-413526a688287ae466b617e0190c17286a1954be.tar.gz
nextcloud-server-413526a688287ae466b617e0190c17286a1954be.zip
Merge pull request #45215 from nextcloud/backport/45058/stable29
[stable29] perf(db): Sort data for IN before chunking
-rw-r--r--lib/private/Files/Cache/Cache.php3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index 62e1e57a171..5267b8a8153 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();