Index creation Occasions:
①where the Back field is suitable for indexing
②order by sort fields suitable for indexing
③ index Overwrite that is, the field you are querying is the index that queries the data directly in the index. For example, select Name,age from man where Name,age itself has an index.
④ Table Query (foreign key set index) in a production activity, the foreign key index is not generally used. Instead, a normal index is used instead of the foreign key index.
⑤ Creating an indexed field requires a higher degree of dispersion, such as gender, which is not suitable for indexing, (the build will not use the index to walk the table scan form)
Index usage Guidelines
① field Independent SELECT * from man where id+2 =5 such queries are not used, i.e. the so-called field independence principle.
② left principle (when fuzzy query) like query time, left fixed may use to index. The left is not fixed and the index cannot be used.
③ composite Index You can use indexes when you use composite cables in full. Using the first index alone, you can use it to the index. Using the second field alone cannot be used to index.
④or principle the index can be used if both sides have indexes. An index that has no index cannot be used to the index, regardless of the order of the or conditions.
MySQL building indexing and indexing use