aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Files/Cache
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2023-06-08 17:14:18 +0200
committerRobin Appelman <robin@icewind.nl>2023-08-14 18:08:01 +0200
commit658aed27ea06e03ae92c9cf1637936dc513b9f64 (patch)
tree6e4a11da79caf2c01245fa81b0f5ee78a5c06613 /lib/private/Files/Cache
parent2ea6c5364dfd672576824b65c1120c17b8c25c0f (diff)
downloadnextcloud-server-658aed27ea06e03ae92c9cf1637936dc513b9f64.tar.gz
nextcloud-server-658aed27ea06e03ae92c9cf1637936dc513b9f64.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/Files/Cache')
-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 287966e4a28..e2630879414 100644
--- a/lib/private/Files/Cache/Cache.php
+++ b/lib/private/Files/Cache/Cache.php
@@ -1012,8 +1012,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)))
@@ -1021,15 +1025,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;
}
/**