Merge pull request #45213 from nextcloud/backport/45058/stable27

[stable27] perf(db): Sort data for IN before chunking
This commit is contained in:
Daniel 2024-06-04 12:50:24 +02:00 committed by GitHub
commit 849587ae2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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();