Search code examples
mysqlindexingfieldunique

MySQL: unique field needs to be an index?


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?


Solution

  • 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.