SQL提示
SQL提示是优化数据库的一个重要手段,简单来说,就是在SQL语句中加入一些人为的提示来达到优化操作的目的
1、告诉数据库,我们要使用哪个索引
use index
例如: explain select * from tb_user use index(idx_use_pro) where profession = '软件工程';
2、告诉数据库,不可以使用哪个索引
ignore index
例如: explain select * from tb_user ignore index(idx_user_pro) where profession = '软件工程';
3、告诉数据库,必须使用哪个索引
force index
例如: explain select * from tb_user force index(idx_user_pro) where profession = '软件工程';
使用场景: 当某个字段有多个索引时,强制MySQL按照我们指定的索引来进行查询