Mysql:唯一字段需要索引吗? [英] Mysql: Unique field need to be index?

查看:185
本文介绍了Mysql:唯一字段需要索引吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的桌子中有一个独特的字段,我需要快速搜索它。我是否需要对其进行索引?

I have one unique field in my table, and I need to search over it quickly. Do I need to index it?

对唯一字段和索引字段的搜索在速度或资源使用方面是否有所不同?

Do searches over unique fields and indexed fields vary in speed or resource usage?

推荐答案

,您不必再次索引它。指定 UNIQUE KEY 时,该列将被编入索引。因此它与相同类型的其他索引列(例如PRIMARY KEY)的性能没有区别。

No, you dont have to index it again. When you specify UNIQUE KEY, the column is indexed. So it has no difference in performance with other indexed column (e.g. PRIMARY KEY) of same type.

但是如果类型不同,那么会有很小的表现差异。

However if the type is different, there will be little performance difference.

这篇关于Mysql:唯一字段需要索引吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆