aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2024-08-12 16:13:58 +0200
committerRobin Appelman <robin@icewind.nl>2024-08-15 17:13:57 +0200
commit0f9ea1992c64cb9cd0fd0193285e118212191726 (patch)
tree82437e5451be5538fa5607d0fbe33cfb617d25db /apps
parent15550de8ce2217b49e64c2ba62f79087c09cf785 (diff)
downloadnextcloud-server-0f9ea1992c64cb9cd0fd0193285e118212191726.tar.gz
nextcloud-server-0f9ea1992c64cb9cd0fd0193285e118212191726.zip
perf: improve cleanup of tags/comments
delete entire chunk at once instead of one-by-one Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/files/lib/BackgroundJob/DeleteOrphanedItems.php15
1 files changed, 6 insertions, 9 deletions
diff --git a/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php b/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php
index a4b2a6cf3f8..0d6a632db1a 100644
--- a/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php
+++ b/apps/files/lib/BackgroundJob/DeleteOrphanedItems.php
@@ -66,18 +66,15 @@ class DeleteOrphanedItems extends TimedJob {
$deleteQuery = $this->connection->getQueryBuilder();
$deleteQuery->delete($table)
- ->where($deleteQuery->expr()->eq($idCol, $deleteQuery->createParameter('objectid')));
+ ->where($deleteQuery->expr()->in($idCol, $deleteQuery->createParameter('objectid')));
$deletedInLastChunk = self::CHUNK_SIZE;
while ($deletedInLastChunk === self::CHUNK_SIZE) {
- $result = $query->execute();
- $deletedInLastChunk = 0;
- while ($row = $result->fetch()) {
- $deletedInLastChunk++;
- $deletedEntries += $deleteQuery->setParameter('objectid', (int) $row[$idCol])
- ->execute();
- }
- $result->closeCursor();
+ $chunk = $query->executeQuery()->fetchAll(\PDO::FETCH_COLUMN);
+ $deletedInLastChunk = count($chunk);
+
+ $deleteQuery->setParameter('objectid', $chunk, IQueryBuilder::PARAM_INT_ARRAY);
+ $deletedEntries += $deleteQuery->executeStatement();
}
return $deletedEntries;