1. A field of a table is worth a higher degree of dispersion, which is more appropriate for the keyword chosen for indexing. The primary key field and the Uniqueness Constraint field are suitable for keywords that are selected for indexing because the values of these fields are very discrete. Especially when you create an index on a primary key field, the value of cardinality (cardinality, set) is equal to the number of rows in that table. MySQL is thoughtful when it comes to dealing with primary KEY constraints and uniqueness constraints. While the database user creates the primary key constraint, MySQL automatically creates the primary index (primary index), and the index name is primary; When a database user creates a unique index, MySQL automatically creates a uniqueness index (unique index), and by default, the index is named unique The name of the field for the sex index.
2. A field that occupies less storage space is more suitable for keywords that are selected for indexing. For example, an integer field occupies less storage space than a string, so it is preferable to select the index keyword.
3. The field with fixed storage space is more suitable for the keyword chosen as index. Fields of type char are better suited to be selected as Index keywords than fields of type text.
4. The fields that are used frequently in the Where clause should be indexed, the grouping field or the Sort field should be indexed, and the connection fields of the two tables should create an index.
5. Fields that are frequently updated are not suitable for creating indexes, and fields that do not appear in the WHERE clause should not be created.
6, the leftmost prefix principle.
7, try to use prefix index.
Under what circumstances the database is suitable for adding indexes