Http://www.hcbus.com/topic/9235/
The structure used by the unique index and the common index is B-tree, and the execution time complexity is O (log n ).
1. Common Index
The only task of a common index (index defined by the key or index keyword) is to speed up data access. Therefore, you should create an index only for the data columns that most frequently appear in the query condition (wherecolumn =) or sort condition (orderbycolumn. If possible, you should select the most neat and compact data column (such as an integer data column) to create an index.
2. Unique Index
Normal indexes allow indexed data columns to contain duplicate values. For example, because a person may have the same name, the same name may appear twice or more times in the same "employee profile" data table.
If you can determine that a data column will only contain different values, you should use the keyword unique to define it as a unique index when creating an index for this data column. The advantage of doing so: First, it simplifies MySQL's management of this index, and this index becomes more efficient. Second, MySQL inserts a data table with a new record, automatically checks whether the value of this field of the new record has already exists in this field of a record; if yes, MySQL rejects the insert of that new record. That is to say, the unique index can ensure the uniqueness of data records. In fact, in many cases, the purpose of creating a unique index is not to speed up access, but to avoid data duplication.