-
Notifications
You must be signed in to change notification settings - Fork 282
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
[stable23] Use explicit cast to make use of index #3497
Conversation
Looks like it makes sense. It was not added so far as currently it was only needed for oracle and postgres when dealing with TEXT and having to convert that to CHAR for comparisons. |
a1c1793
to
eb1944d
Compare
997cb28
to
47a655d
Compare
Changed the base to 23 since on 24 we have this fixed in the server. |
/backport to stable22 |
/backport to stable21 |
Signed-off-by: Julius Härtl <[email protected]>
47a655d
to
c04e5c1
Compare
$cardIdExpression = $qb->createFunction('CAST(dc.id as CHAR)'); | ||
} else { | ||
$cardIdExpression = $qb->expr()->castColumn('dc.id', IQueryBuilder::PARAM_STR); | ||
} |
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.
The snippet is used twice in the code. I think it would be a good idea to create a temp function for that as that function will be removed in the coming version of nextcloud.
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.
For newer server releases this will be taken care of in the query builder abstraction with nextcloud/server#30471, so I'd say we stick to those now for the bugfix only releases.
This ensures that indexes of oc_share are being used on MySQL when fetching the shares of a user during mountpoint setup, where otherwise a full table scan would happen.
@nickvergessen I'm wondering if there is a specific reason that the MySQLExpressionBuilder does not implement any actual casting when using castColumn(). Is that something that we should rather do in the server then maybe?
EXPLAIN before
EXPLAIN after