FORCE INDEX IGNORE INDEX

MySQL :: MySQL 8.0 Reference Manual :: 8.9.4 Index Hints https://dev.mysql.com/doc/refman/8.0/en/index-hints.html

MySQL :: MySQL 8.0 Reference Manual :: 8.9.3 Optimizer Hints https://dev.mysql.com/doc/refman/8.0/en/optimizer-hints.html#optimizer-hints-index-level

Mysql中的force index和ignore index -  博客园 https://www.cnblogs.com/sdadx/p/8391985.html
明明表中有这个索引,但mysql的force index 无效?_force index 不生效 CSDN博客 https://blog.csdn.net/LJFPHP/article/details/99989001

 

sql优化器

 

CREATE TABLE `t0` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`v` INT(11) NULL DEFAULT NULL,
`uid` INT(11) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE,
INDEX `idx_v` (`v`) USING BTREE,
INDEX `idx_uid` (`uid`) USING BTREE
)
COLLATE='utf8_unicode_ci'
ENGINE=InnoDB
;

EXPLAIN SELECT * FROM t0 WHERE v>1 AND uid=123;

 EXPLAIN SELECT * FROM t0 FORCE INDEX (idx_v) WHERE v>1 AND uid=123;

 

 

 

 

posted @ 2023-06-19 11:30  papering  阅读(14)  评论(0编辑  收藏  举报