Merge pull request #45214 from nextcloud/backport/45058/stable28

[stable28] perf(db): Sort data for IN before chunking
This commit is contained in:
Josh 2024-05-29 11:02:26 -04:00 committed by GitHub
commit 8d2502aca2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -623,6 +623,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();