mysql強制索引和禁止某個索引

2021-07-24 16:31:59 字數 581 閱讀 9915

1、mysql強制使用索引:force index(索引名或者主鍵pri)

例如:select * from table force index(pri) limit 2;(強制使用主鍵)

select * from table force index(ziduan1_index) limit 2;(強制使用索引"ziduan1_index")

select * from table force index(pri,ziduan1_index) limit 2;(強制使用索引"pri和ziduan1_index")

2、mysql禁止某個索引:ignore index(索引名或者主鍵pri)

例如:select * from table ignore index(pri) limit 2;(禁止使用主鍵)

select * from table ignore index(ziduan1_index) limit 2;(禁止使用索引"ziduan1_index")

select * from table ignore index(pri,ziduan1_index) limit 2;(禁止使用索引"pri,ziduan1_index")

MYSQL強制使用索引和禁止使用索引

1 mysql強制使用索引 force index 索引名或者主鍵pri 例如 select from table force index pri limit 2 強制使用主鍵 select from table force index ziduan1 index limit 2 強制使用索引 zi...

MYSQL強制使用索引和禁止使用索引

mysql強制索引和禁止某個索引 1 mysql強制使用索引 force index 索引名或者主鍵pri 例如 select from table force index pri limit 2 強制使用主鍵 select from table force index ziduan1 index ...

mysql索引hash索引和b tree索引的區別

mysql下增加索引的方式 修改表結構 alter mytable add index indexname on username length 建立表結構 create table mytable id int not null,username varchar 16 not null,index...