Skip to content

Commit 2ab0bb7

Browse files
committed
Use optimized inner join to mark parent as outdated
Signed-off-by: Ari Selseng <ari@selseng.net>
1 parent 1b27e95 commit 2ab0bb7

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

apps/files_external/lib/Command/Notify.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,15 @@ private function markParentAsOutdated($mountId, $path, OutputInterface $output)
161161
$parent = '';
162162
}
163163

164+
$pathHash = md5(trim(\OC_Util::normalizeUnicode($parent), '/'));
164165
try {
165-
$this->updateQuery->execute([$parent, $mountId]);
166+
$this->updateQuery->execute([$mountId, $pathHash]);
166167
} catch (DriverException $ex) {
167168
$this->logger->logException($ex, ['app' => 'files_external', 'message' => 'Error while trying to mark folder as outdated', 'level' => ILogger::WARN]);
168169
$this->connection = $this->reconnectToDatabase($this->connection, $output);
169170
$output->writeln('<info>Needed to reconnect to the database</info>');
170171
$this->updateQuery = $this->getUpdateQuery($this->connection);
171-
$this->updateQuery->execute([$parent, $mountId]);
172+
$this->updateQuery->execute([$mountId, $pathHash]);
172173
}
173174
}
174175

@@ -204,9 +205,11 @@ private function logUpdate(IChange $change, OutputInterface $output) {
204205
private function getUpdateQuery(IDBConnection $connection) {
205206
// the query builder doesn't really like subqueries with parameters
206207
return $connection->prepare(
207-
'UPDATE *PREFIX*filecache SET size = -1
208-
WHERE `path` = ?
209-
AND `storage` IN (SELECT storage_id FROM *PREFIX*mounts WHERE mount_id = ?)'
208+
'UPDATE *PREFIX*filecache
209+
INNER JOIN *PREFIX*mounts
210+
ON (*PREFIX*filecache.storage = *PREFIX*mounts.storage_id)
211+
SET size = -1
212+
WHERE `path_hash` = ?'
210213
);
211214
}
212215

0 commit comments

Comments
 (0)