]> source.dussan.org Git - nextcloud-server.git/commitdiff
Search without join on filecache_extended 32994/head
authorCarl Schwan <carl@carlschwan.eu>
Thu, 23 Jun 2022 14:18:07 +0000 (16:18 +0200)
committerCarl Schwan <carl@carlschwan.eu>
Thu, 23 Jun 2022 14:23:52 +0000 (16:23 +0200)
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
lib/private/Files/Cache/CacheQueryBuilder.php
lib/private/Files/Cache/QuerySearchHelper.php

index b92e79aa229856183303769e8df843e95b6542a7..496a8361d77482f8d2dd5b29812b02ee51a385a8 100644 (file)
@@ -41,12 +41,16 @@ class CacheQueryBuilder extends QueryBuilder {
                parent::__construct($connection, $systemConfig, $logger);
        }
 
-       public function selectFileCache(string $alias = null) {
+       public function selectFileCache(string $alias = null, bool $joinExtendedCache = true) {
                $name = $alias ? $alias : 'filecache';
                $this->select("$name.fileid", 'storage', 'path', 'path_hash', "$name.parent", "$name.name", 'mimetype', 'mimepart', 'size', 'mtime',
-                       'storage_mtime', 'encrypted', 'etag', 'permissions', 'checksum', 'metadata_etag', 'creation_time', 'upload_time', 'unencrypted_size')
-                       ->from('filecache', $name)
-                       ->leftJoin($name, 'filecache_extended', 'fe', $this->expr()->eq("$name.fileid", 'fe.fileid'));
+                       'storage_mtime', 'encrypted', 'etag', 'permissions', 'checksum', 'unencrypted_size')
+                       ->from('filecache', $name);
+
+               if ($joinExtendedCache) {
+                       $this->addSelect('metadata_etag', 'creation_time', 'upload_time');
+                       $this->leftJoin($name, 'filecache_extended', 'fe', $this->expr()->eq("$name.fileid", 'fe.fileid'));
+               }
 
                $this->alias = $name;
 
index e7bccbf521c26db3bb920646878dd9cd77d0ce49..69a2944b2dd4d9fa6e8b62331aef268692835892 100644 (file)
@@ -103,7 +103,7 @@ class QuerySearchHelper {
 
                $builder = $this->getQueryBuilder();
 
-               $query = $builder->selectFileCache('file');
+               $query = $builder->selectFileCache('file', false);
 
                if ($this->searchBuilder->shouldJoinTags($searchQuery->getSearchOperation())) {
                        $user = $searchQuery->getUser();