perf(db): Sort data for IN before chunking

Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
Christoph Wurst 2024-04-26 15:38:29 +02:00
parent 10af08736e
commit f3d6309e36
No known key found for this signature in database
GPG Key ID: CC42AC2A7F0E56D8
1 changed files with 3 additions and 0 deletions

View File

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