gpt4 book ai didi

mysql - 在 MySQL 中,当我的 where 子句中有 in "in"条件时,我可以使用索引吗?

转载 作者:行者123 更新时间:2023-11-29 15:37:38 24 4
gpt4 key购买 nike

给出这个查询;

select my_field1
from my_table
where my_field2 in ('five', 'six')

如果我在 my_field2 上有索引,则不会使用它。有没有办法优化它以利用我的索引?

最佳答案

当“基数”较低时,优化器会选择忽略索引。这是因为简单地扫描整个表可能比在 INDEX's 之间来回跳动更快。 BTree 和数据 BTree。

关于mysql - 在 MySQL 中,当我的 where 子句中有 in "in"条件时,我可以使用索引吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58079098/

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