gpt4 book ai didi

mysql - 强制 mysql 以某种方式使用索引

转载 作者:行者123 更新时间:2023-11-29 14:02:42 25 4
gpt4 key购买 nike

我发现,当针对我们的 MySQL 数据库 (5.5.27) 运行查询时,当优化器选择使用索引作为范围时,它会快速响应,但当它选择 ref_or_null 时,它会花费更长的时间。

有没有办法强制索引始终使用范围?

最佳答案

如果您确定优化器没有正确使用索引,您可以尝试使用索引提示。

SELECT * FROM table1 USE INDEX (col1_index,col2_index)
WHERE col1=1 AND col2=2 AND col3=3;

Documentation

关于mysql - 强制 mysql 以某种方式使用索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14821311/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com