Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Move query outside the loop and reduce chunk size to 1000
This involved changing CacheQueryBuilder\whereParentIn to take a
parameter name, renaming the function accordingly.

Signed-off-by: Sijmen Schoon <[email protected]>
  • Loading branch information
vijfhoek authored and backportbot[bot] committed Nov 1, 2021
commit d987fd32ef58d59d8e75a827731d9fd92ca0e572
22 changes: 12 additions & 10 deletions lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,12 @@ private function removeChildren(ICacheEntry $entry) {
return $cacheEntry->getId();
}, $children);

$childIdChunks = array_chunk($childIds, 2048);
foreach ($childIdChunks as $childIdChunk) {
$query = $this->getQueryBuilder();
$query->delete('filecache_extended')
->where($query->expr()->in('fileid', $query->createNamedParameter($childIdChunk, IQueryBuilder::PARAM_INT_ARRAY)));
$query = $this->getQueryBuilder();
$query->delete('filecache_extended')
->where($query->expr()->in('fileid', $query->createParameter('childIds')));

foreach (array_chunk($childIds, 1000) as $childIdChunk) {
$query->setParameter('childIds', $childIdChunk, IQueryBuilder::PARAM_INT_ARRAY);
$query->execute();
}

Expand All @@ -602,11 +603,12 @@ private function removeChildren(ICacheEntry $entry) {
}
}

$parentIdChunks = array_chunk($parentIds, 2048);
foreach ($parentIdChunks as $parentIdChunk) {
$query = $this->getQueryBuilder();
$query->delete('filecache')
->whereParentIn($parentIdChunk);
$query = $this->getQueryBuilder();
$query->delete('filecache')
->whereParentInParameter('parentIds');

foreach (array_chunk($parentIds, 1000) as $parentIdChunk) {
$query->setParameter('parentIds', $parentIdChunk, IQueryBuilder::PARAM_INT_ARRAY);
$query->execute();
}
}
Expand Down
4 changes: 2 additions & 2 deletions lib/private/Files/Cache/CacheQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ public function whereParent(int $parent) {
return $this;
}

public function whereParentIn(array $parents) {
public function whereParentInParameter(string $parameter) {
$alias = $this->alias;
if ($alias) {
$alias .= '.';
} else {
$alias = '';
}

$this->andWhere($this->expr()->in("{$alias}parent", $this->createNamedParameter($parents, IQueryBuilder::PARAM_INT_ARRAY)));
$this->andWhere($this->expr()->in("{$alias}parent", $this->createParameter($parameter)));

return $this;
}
Expand Down