gpt4 book ai didi

mysql - Varchar 上的索引是否会产生性能差异?

转载 作者:IT老高 更新时间:2023-10-28 12:59:45 29 4
gpt4 key购买 nike

varchar 列上的索引是否会使查询运行速度变慢?我可以把它变成int。而且我不需要进行 LIKE % 比较。

最佳答案

Does index on a varchar column make the query run slower?

不,它没有。
如果优化器决定使用索引,查询将运行得更快。该表上的 INSERTs/UPDATEs/DELETE 会较慢,但不太可能引起注意。

I don't need to do the LIKE % comparison

注意使用:

LIKE '%whatever%'

...将使用索引,但以下将:

LIKE 'whatever%'

键是字符串左侧的通配符意味着不能使用列上的索引。

还知道MySQL limits the amount of space set aside for indexes - 对于 MyISAM(InnoDB 为 767 字节)表,它们最长可达 1000 字节。

关于mysql - Varchar 上的索引是否会产生性能差异?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1898453/

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