IGNORE INDEX
Syntax
IGNORE INDEX [{FOR {JOIN|ORDER BY|GROUP BY}] ([index_list])
Description
You can tell the optimizer to not consider a particular index with the IGNORE INDEX option.
The benefit of using IGNORE_INDEX instead of USE_INDEX is that it will not disable a new index which you may add later.
Also see Ignored Indexes for an option to specify in the index definition that indexes should be ignored.
Index Prefixes
When using index hints (USE, FORCE or IGNORE INDEX), the index name value can also be an unambiguous prefix of an index name.
Example
This is used after the table name in the FROM clause:
CREATE INDEX Name ON City (Name); CREATE INDEX CountryCode ON City (Countrycode); EXPLAIN SELECT Name FROM City IGNORE INDEX (Name) WHERE name="Helsingborg" AND countrycode="SWE";
This produces:
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE City ref CountryCode CountryCode 3 const 14 Using where
See Also
- See Index Hints: How to Force Query Plans for more details
- USE INDEX
- FORCE INDEX
- Ignored Indexes
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.
© 2021 MariaDB
Licensed under the Creative Commons Attribution 3.0 Unported License and the GNU Free Documentation License.
https://mariadb.com/kb/en/ignore-index/