-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Index hints #9421
Comments
Okay, I think a good starting point might be to go over SQL capabilities, and how/if we want to implement all of these. Valid MySQL queries:
I think 1, 2, and 3 are all reasonable functionality. I don't see any reason why we would need to implement 4. As far as I know, 4 is simply a syntactically different way to represent 3, without adding any new functionality (I could be wrong). Note: It is perfectly valid to use the same index more than once in an index hint. |
Also, it looks like all 3 Pull Requests referenced in the original post are for MySQL. I don't think there is any actual demand for this feature outside of the MySQL dialect; at least nothing that I have been able to find online. |
Agree with you @jwt1143 on my PR I was able to pass a collection of indexes. I like option
|
Also, I like to support the ability to use |
is not rare at all for very large databases |
Okay. I think it makes sense to support force (and probably ignore too in that case). Here's an API proposal: We add an
Examples:SELECT * FROM t1 USE INDEX ();
SELECT * FROM t1 USE INDEX (i1);
SELECT * FROM t1 USE INDEX (i1,i2);
SELECT * FROM t1 FORCE INDEX (i1);
SELECT * FROM t1 IGNORE INDEX (i1);
SELECT * FROM t1 USE INDEX (i1,i2) IGNORE INDEX (i2);
NotesI prefer using objects over arrays to represent each index hint because they are more explicit.
is not nearly as clear as
Being more verbose shouldn't be an issue as indexHints are only used in limited/rare circumstances. |
@jwt1143 Your proposal looks good, some comments
indexHints: [
{ type: IndexHints.USE || FORCE || IGNORE, values: ["i1","i2"] },
] I also do perfer object based approach indexHints: [
{ type: IndexHints.USE, values: ["i1","i2"] },
] As for implementation MSSQL We are only going to introduce this WITH (TableHints, INDEX (<index>)) Form of table hint expansion, we already support table hints for MSSQL, we just need to include index part when SQLite Only need to add INDEXED BY <index_name> For any given MySQL Up to you, as that is your primary objective with this issue |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Will the indexHints option support |
@benjamin658 Thanks for adding it on #11573 :) |
MySQL supports index hints on JOIN statements. It'd be nice to be able to do this:
and get something like this:
PR incoming. |
Is it possible to get indexHints enabled with sql server / tedious? |
@timbowhite The index hints on JOIN statements features would be so life saving 🙏 |
Any workaround in v3? |
Related support information
Pull requests #9378 , #9409, #8401, #11573
The text was updated successfully, but these errors were encountered: