mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
tell mysql to ignore the sort index for search queries
mysql really likes to pick an index for sorting if it can't fully satisfy the where filter with an index, since search queries pretty much never are fully filtered by index mysql often picks an index for sorting instead of the *much* more useful index for filtering. To bypass this, we tell mysql explicitly not to use the mtime (the default order field) index, so it will instead pick an index that is actually useful. Signed-off-by: Robin Appelman <robin@icewind.nl>
This commit is contained in:
parent
7f272dd98f
commit
5002bf9cc1
1 changed files with 7 additions and 1 deletions
|
|
@ -840,7 +840,13 @@ class Cache implements ICache {
|
|||
protected function buildSearchQuery(ISearchQuery $searchQuery): IQueryBuilder {
|
||||
$builder = $this->getQueryBuilder();
|
||||
|
||||
$query = $builder->selectFileCache('file');
|
||||
// mysql really likes to pick an index for sorting if it can't fully satisfy the where
|
||||
// filter with an index, since search queries pretty much never are fully filtered by index
|
||||
// mysql often picks an index for sorting instead of the *much* more useful index for filtering.
|
||||
//
|
||||
// To bypass this, we tell mysql explicitly not to use the mtime (the default order field) index,
|
||||
// so it will instead pick an index that is actually useful.
|
||||
$query = $builder->selectFileCache('file', 'ignore index for order by (fs_mtime)');
|
||||
|
||||
$query->whereStorageId();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue