简体   繁体   English

是否在索引mysql表中的列之前插入索引的值

[英]Are values indexed that are inserted before the column in mysql table is indexed

So lets say I have column email in table user. 因此,可以说我在表用户中有列电子邮件。 And I created the table user email column is not neither foreign key , or unique or whatever that is indexed. 而且我创建的表用户电子邮件列既不是外键,也不是唯一的,也不是被索引的。 After that I'm adding index to the column email. 之后,我将索引添加到列电子邮件中。 Do the values, before adding index in the email column, have indexed or not? 在电子邮件列中添加索引之前,这些值是否已索引?

Yes. 是。

When you create an index (be it a simple index, or a special case like unique/primary/...), the database will index all values that are already in the table . 创建索引(无论是简单索引还是特殊情况,例如unique / primary / ...)时, 数据库都会索引表中已存在的所有值

This is why for a small (empty) table, creating an index can be fast, but for a large table, it can take much longer. 这就是为什么对于小型(空)表而言,创建索引的速度很快,而对于大型表而言,则需要花费更长的时间。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM