mirror of
https://github.com/nextcloud/server.git
synced 2026-02-20 00:12:30 -05:00
select the fileid first when looking for incomplete files
this seems to improve mariadbs index selection Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
2ea6c5364d
commit
658aed27ea
1 changed files with 9 additions and 5 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue