Disabling an optimization prevents the optimizer from using it. Enabling an optimization means the optimizer is free to use the strategy if it applies to statement execution, not that the optimizer necessarily uses it. 

## Optimizer Hint Syntax 

MySQL supports comments in SQL statements as described in Section 9.7, “Comments” . Optimizer hints must be specified within /*+ ... */  comments. That is, optimizer hints use a variant of /* ... */  C- style comment syntax, with a +  character following the /*  comment opening sequence. Examples: 

/*+ BKA(t1) */ /*+ BNL(t1, t2) */ /*+ NO_RANGE_OPTIMIZATION(t4 PRIMARY) */ /*+ QB_NAME(qb2) */ 

Whitespace is permitted after the +  character. 

The parser recognizes optimizer hint comments after the initial keyword of SELECT , UPDATE , INSERT , REPLACE , and DELETE  statements. Hints are permitted in these contexts: 

•At the beginning of query and data change statements: 

SELECT /*+ ... */ ... INSERT /*+ ... */ ... REPLACE /*+ ... */ ... UPDATE /*+ ... */ ... DELETE /*+ ... */ ... 

•At the beginning of query blocks: 

(SELECT /*+ ... */ ... ) (SELECT ... ) UNION (SELECT /*+ ... */ ... ) (SELECT /*+ ... */ ... ) UNION (SELECT /*+ ... */ ... ) UPDATE ... WHERE x IN (SELECT /*+ ... */ ...) INSERT ... SELECT /*+ ... */ ... 

•In hintable statements prefaced by EXPLAIN . For example: 

EXPLAIN SELECT /*+ ... */ ... EXPLAIN UPDATE ... WHERE x IN (SELECT /*+ ... */ ...) 

The implication is that you can use EXPLAIN  to see how optimizer hints affect execution plans. Use SHOW WARNINGS  immediately after EXPLAIN  to see how hints are used. The extended EXPLAIN output displayed by a following SHOW WARNINGS  indicates which hints were used. Ignored hints are not displayed. 

A hint comment may contain multiple hints, but a query block cannot contain multiple hint comments. This is valid: 

SELECT /*+ BNL(t1) BKA(t2) */ ... 

But this is invalid: 

SELECT /*+ BNL(t1) */ /* BKA(t2) */ ... 

When a hint comment contains multiple hints, the possibility of duplicates and conflicts exists. The following general guidelines apply. For specific hint types, additional rules may apply, as indicated in the hint descriptions. 

•Duplicate hints: For a hint such as /*+ MRR(idx1) MRR(idx1) */ , MySQL uses the first hint and issues a warning about the duplicate hint. 

