MySQL Index 索引提示:force or use

一、使用索引提示(Index Hint)的条件

1、Mysql优化器错误的选择了某个索引。这种情况很少发生,需要做数据库的表、索引的统计分析。

2、某个SQL语句可选择的索引非常多,这个时候优化器执行计划时间的开销可能会大于SQL语句本身。

二、实现Index Hint两种方式

1、Force Index

sleect * from t force index(a) where a=1 and b=2;

2、Use Index

select * from t use index(a) where a=1 and b=2;

原文地址:https://www.cnblogs.com/xibuhaohao/p/10913247.html