aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2024-04-26 15:38:29 +0200
committerJosh <josh.t.richards@gmail.com>2024-05-25 20:50:56 -0400
commitb226039fe9c6aab8950165923ffba9d75fafaa74 (patch)
tree04fef1713c3993b976bc98f2aec86eef1087dbdc
parentb127e020ec7edb4ae2bde89e3eaea13bd081f494 (diff)
downloadnextcloud-server-b226039fe9c6aab8950165923ffba9d75fafaa74.tar.gz
nextcloud-server-b226039fe9c6aab8950165923ffba9d75fafaa74.zip
perf(db): Sort data for IN before chunking
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
-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 5a3e38dd569..9822b6874f9 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -629,6 +629,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();