经常使用Oracle的人都知道Oracle的hint 提示功能特别强大,MySQL也有类似的功能,下面是一些MySQL常用的hint 提示。
强制索引 FORCE INDEX
select * from table1 force index (field1) …
忽略索引 IGNORE INDEX
select * from table1 ignore index (field1, field2) …
关闭查询缓冲 SQL_NO_CACHE
select sql_no_cache field1, field2 from table1;
强制查询缓冲 SQL_CACHE
select sql_calhe * from table1;
强制连接顺序 STRAIGHT_JOIN
select table1.field1, table2.field2 from table1 straight_join table2 where …
强制使用临时表 SQL_BUFFER_RESULT
select sql_buffer_result * from table1 where …