-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tell mysql to ignore the sort index for search queries #29300
Conversation
Signed-off-by: Robin Appelman <robin@icewind.nl>
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>
/backport to stable22 |
$this->add('join', [ | ||
$this->quoteAlias($name) => [ | ||
// horrible query builder crimes to sneak in raw sql after the "FROM oc_filecache $name" | ||
'joinType' => $mysqlIndexHint . ' left', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what would be a clean way ? is this something that could be added upstream ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would have to be added upstream (the design of the query builder doesn't really make it possible to overwrite internal parts of it) but upstream is (understandably) hesitant about adding features that only apply on one specific db backend.
While this is certainly not a nice way to do this, it is the best option I'm aware of and doesn't require waiting for upstream releases.
Bump? What is the status? |
replaced with #32074 |
Involves some creative query builder usage to sneak the index hint into the query
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.