summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-06-08 17:14:18 +0200
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>2023-08-14 19:15:41 +0000
commit690d9bac5e0513e73f5a128c3b2fc45e415091f9 (patch)
treed020d998928319e62cf4198bc2466f9262b392da /lib/private
parent649175f9ff94c0587287efc68a233448481a5511 (diff)
downloadnextcloud-server-690d9bac5e0513e73f5a128c3b2fc45e415091f9.tar.gz
nextcloud-server-690d9bac5e0513e73f5a128c3b2fc45e415091f9.zip
select the fileid first when looking for incomplete files
this seems to improve mariadbs index selection Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Files/Cache/Cache.php14
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/private/Files/Cache/Cache.php b/lib/private/Files/Cache/Cache.php
index bf459b2ff86..9805fd1601f 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -984,8 +984,12 @@ class Cache implements ICache {
* @return string|false the path of the folder or false when no folder matched
*/
public function getIncomplete() {
+ // we select the fileid here first instead of directly selecting the path since this helps mariadb/mysql
+ // to use the correct index.
+ // The overhead of this should be minimal since the cost of selecting the path by id should be much lower
+ // than the cost of finding an item with size < 0
$query = $this->getQueryBuilder();
- $query->select('path')
+ $query->select('fileid')
->from('filecache')
->whereStorageId($this->getNumericStorageId())
->andWhere($query->expr()->lt('size', $query->createNamedParameter(0, IQueryBuilder::PARAM_INT)))
@@ -993,15 +997,15 @@ class Cache implements ICache {
->setMaxResults(1);
$result = $query->execute();
- $path = $result->fetchOne();
+ $id = $result->fetchOne();
$result->closeCursor();
- if ($path === false) {
+ if ($id === false) {
return false;
}
- // Make sure Oracle does not continue with null for empty strings
- return (string)$path;
+ $path = $this->getPathById($id);
+ return $path ?? false;
}
/**