Index hints give the optimizer information about how to choose indexes during query processing. Index hints, described here, differ from optimizer hints, described in Section 8.9.3, “Optimizer Hints”. Index and optimizer hints may be used separately or together.
索引提示向优化器提供关于在查询处理期间如何选择索引的信息。这里描述的索引提示不同于8.9.3节“优化器提示”中描述的优化器提示。索引和优化器提示可以单独使用,也可以一起使用。
Index hints apply only to SELECT and UPDATE statements.
索引提示仅适用于SELECT和UPDATE语句。
Index hints are specified following a table name. (For the general syntax for specifying tables in a SELECT statement, see Section 13.2.9.2, “JOIN Clause”.) The syntax for referring to an individual table, including index hints, looks like this:
索引提示在表名之后指定。(在SELECT语句中指定表的一般语法,请参见13.2.9.2节“JOIN子句”。)引用单个表(包括索引提示)的语法如下:
The USE INDEX (
hint tells MySQL to use only one of the named indexes to find rows in the table. The alternative syntax index_list
)IGNORE INDEX (
tells MySQL to not use some particular index or indexes. These hints are useful if EXPLAIN shows that MySQL is using the wrong index from the list of possible indexes. index_list
)