Skip to content

Commit

Permalink
perf(db): Sort data for IN before chunking
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
  • Loading branch information
ChristophWurst authored and backportbot[bot] committed May 7, 2024
1 parent 9f7d574 commit c95a0ca
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,9 @@ private function removeChildren(ICacheEntry $entry) {
$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();
Expand Down

0 comments on commit c95a0ca

Please sign in to comment.