diff options
author | Sijmen Schoon <me@sijmenschoon.nl> | 2021-10-17 21:52:38 +0300 |
---|---|---|
committer | Sijmen Schoon <me@sijmenschoon.nl> | 2021-10-17 21:57:28 +0300 |
commit | 34600c78bbda8fa232f474936ccbebbfd97c1209 (patch) | |
tree | b9c87fb598531d58895fa11aa3441b8a289fae12 /lib/private/Files/Cache | |
parent | c959bf2b426aa2e5ad53892d9685b9c33261aadf (diff) |
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>
Diffstat (limited to 'lib/private/Files/Cache')
-rw-r--r-- | lib/private/Files/Cache/Cache.php | 22 | ||||
-rw-r--r-- | lib/private/Files/Cache/CacheQueryBuilder.php | 4 |
2 files changed, 14 insertions, 12 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php index f471b5c7838..cba2bae6ed9 100644 --- a/lib/private/Files/Cache/Cache.php +++ b/lib/private/Files/Cache/Cache.php @@ -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(); } } diff --git a/lib/private/Files/Cache/CacheQueryBuilder.php b/lib/private/Files/Cache/CacheQueryBuilder.php index 774691ebc31..87a1f940f20 100644 --- a/lib/private/Files/Cache/CacheQueryBuilder.php +++ b/lib/private/Files/Cache/CacheQueryBuilder.php @@ -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; } |