-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Add support for index / query hints in query builder #9119
Labels
Comments
"use index" is sometimes not enough. Then I would like to use "force index": |
+1. Currently this can be accomplished using an expression, but it's kinda verbose and not database agnostic. Something like so:
|
@Sarke is there a common syntax for forcing index usage across different databases? |
uaoleg
added a commit
to uaoleg/yii2
that referenced
this issue
Sep 2, 2023
uaoleg
added a commit
to uaoleg/yii2
that referenced
this issue
Sep 2, 2023
I've created a PR for this #19946 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think that we should add support for index hinting in the query builder. I've tried simply adding the hint to the FROM clause, but this tends to break things when doing joins because it tries to add the hint string to those as well (which causes parse errors on the database side.
A couple examples of index hints:
MySQL uses
USE INDEX (index_name,index2_name)
MsSQL uses
WITH( INDEX(index_name))
I think that this should probably be it's own function on the query builder so that you can easily change the index based on a where clause you might be building or other conditionals. Just spit balling here:
And could see it being used sort of like this:
The text was updated successfully, but these errors were encountered: