Bug #70299 | Feature request: make an index invisible to the optimizer | ||
---|---|---|---|
Submitted: | 11 Sep 2013 13:47 | Modified: | 2 May 2014 5:15 |
Reporter: | Morgan Tocker | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S4 (Feature request) |
Version: | 5.7+ | OS: | Any |
Assigned to: | Assigned Account | CPU Architecture: | Any |
[11 Sep 2013 13:47]
Morgan Tocker
[2 May 2014 5:15]
Erlend Dahl
Thank you for your feature request.
[22 Jul 2014 15:05]
Lukas Eder
I would agree with this feature request. Another use-case where error messages originating from USE INDEX hints are dangerous is when a database administrator wants to temporarily drop an index to increase insertion speed for some data migration / sanitation while the application(s) are still running. Indexes should be a completely optional part of DDL. The Oracle database, for instance, simply ignores /*+INDEX(...)*/ (and all other hints) if they can no longer be satisfied. Of course, it's still a good idea to log warnings / info about a missing index somewhere.
[10 Jun 2015 15:54]
Morgan Tocker
The new hints in 5.7 work as Lukas describes (warning instead of error) :) http://dev.mysql.com/doc/refman/5.7/en/optimizer-hints.html The existing query hints remain as errors, and not all of these have a corresponding equivalent using the new syntax yet.
[11 Jun 2015 12:26]
Lukas Eder
Ooh, Oracle comment-style syntax! Nice move + pragmatic solution at keeping existing error behaviour the way it is. Looks worth a blog post to me :)
[11 Jun 2015 12:49]
Daniël van Eeden
I think the warning instead of error is good as it maintains the separation between the query (sql) and implementation (database). However with LDAP (e.g. sun dsee) it is possible to disallow queries which don't use an index (result is the "unwilling to perform" error). Which is helpful to prevent full scans. However with InnoDB the PRIMARY is also an index, so this would be hard to do in a useful way. I've recently done some queries with a FORCE INDEX(idx) to make sure it couldn't do a table scan and had to do an index scan. This is basically disabling the fallback. So please consider some options to force index usage and fail otherwise as the fallback might be too expensive.
[2 Nov 2015 13:11]
Daniël van Eeden
Related: https://bugs.mysql.com/bug.php?id=79073