MySQL :: MySQL 8.4 Reference Manual :: B.3.5 Optimizer-Related Issues (original) (raw)

The world's most popular open source database

MySQL uses a cost-based optimizer to determine the best way to resolve a query. In many cases, MySQL can calculate the best possible query plan, but sometimes MySQL does not have enough information about the data at hand and has to make“educated” guesses about the data.

For the cases when MySQL does not do the "right" thing, tools that you have available to help MySQL are:

mysql> EXPLAIN SELECT * FROM t1, t2 WHERE t1.i = t2.i;  

EXPLAIN is discussed in more detail in Section 15.8.2, “EXPLAIN Statement”.

SELECT * FROM t1, t2 FORCE INDEX (index_for_column)  
WHERE t1.col_name=t2.col_name;  

USE INDEX and IGNORE INDEX may also be useful. SeeSection 10.9.4, “Index Hints”.