mysql强制索引和禁止某个索引

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")

 

 

相关文章:

  • 2022-02-01
  • 2022-02-10
  • 2022-01-24
  • 2021-12-08
  • 2022-01-24
  • 2021-12-05
猜你喜欢
  • 2022-02-04
  • 2022-12-23
  • 2022-02-09
  • 2022-12-23
  • 2022-01-29
  • 2022-12-23
  • 2021-06-12
相关资源
相似解决方案