mirror of
https://github.com/nextcloud/server.git
synced 2026-02-27 18:37:17 +01:00
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 <me@sijmenschoon.nl>
This commit is contained in:
@@ -587,11 +587,12 @@ class Cache implements ICache {
|
||||
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();
|
||||
}
|
||||
|
||||
@@ -605,11 +606,12 @@ class Cache implements ICache {
|
||||
}
|
||||
}
|
||||
|
||||
$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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ class CacheQueryBuilder extends QueryBuilder {
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function whereParentIn(array $parents) {
|
||||
public function whereParentInParameter(string $parameter) {
|
||||
$alias = $this->alias;
|
||||
if ($alias) {
|
||||
$alias .= '.';
|
||||
@@ -99,7 +99,7 @@ class CacheQueryBuilder extends QueryBuilder {
|
||||
$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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user