简体   繁体   中英

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 .

This is why for a small (empty) table, creating an index can be fast, but for a large table, it can take much longer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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