Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
select the fileid first when looking for incomplete files
this seems to improve mariadbs index selection

Signed-off-by: Robin Appelman <[email protected]>
  • Loading branch information
icewind1991 committed Aug 28, 2023
commit c8cf2ebf17b022a687ee3352c3342d55583d8ac9
19 changes: 16 additions & 3 deletions lib/private/Files/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -981,19 +981,32 @@ public function getAll() {
* @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)))
->orderBy('fileid', 'DESC')
->setMaxResults(1);

$result = $query->execute();
$path = $result->fetchOne();
$id = $result->fetchOne();
$result->closeCursor();

return $path;
if ($id === false) {
return false;
}

$path = $this->getPathById($id);
if ($path === null) {
return false;
} else {
return $path;
}
}

/**
Expand Down