First, MySQL commonly used index types
1.1 Primary key index
primary key
1.2 Unique Index
unique
1.3 Ordinary index
index
1.4 Full-text indexing
1.5 Combined Index
Second, MySQL commonly used data structures
2.1B-tree
2.2 Hash index
Three, index design principles
3.1 Choose a unique index
The value set to unique can be set as an index, which can quickly locate a record
3.2 Build indexes for fields that often require sorting, grouping, and union operations
Fields that often require order by, group by, distinct, union operations can be set as indexes, because sorting takes a lot of time
3.3 Create indexes for fields that are often used as query conditions
Querying takes a lot of time, so you can use fields that are frequently queried as indexes
3.4 Limit the number of indexes
It’s not that the more the number of indexes, the better, because creating indexes will take up disk space, and when data is updated, in addition to the data in the new database, it must also follow the data in the new index, which complicates the update operation and requires a lot of time.
3.5 Try to use prefixes to index
If the index field is relatively long, try to use the prefix to index, such as TEXT and BLOG types, only need the prefix to locate the corresponding field, if you use the full-text index, it will waste a lot of time
3.6 Try to use indexes with a small amount of data
If all values are long, indexing will also slow down
3.7 Delete indexes that are no longer used or rarely used
The existence of indexes will make table update operations cumbersome and occupy disk space. Unnecessary indexes should be checked regularly and deleted.