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 committed by Josh
parent f0902dbabc
commit 66898f82f1

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