When does mysql use indexes

Index is essentially a data structure, sorted fast search structure: retrieval is fast, sorting is fast,
but insert, update, delete and other update tables will slow down. Because you want to change the table, you also need to change the index. The
index is also a table, which stores the records of the primary key and index field pointing to the entity table, so the index also takes up space.
Those who need to create an index:

  • Primary key is automatically created
  • Frequently used as query conditions
  • Foreign key
  • Composite index is better than single key
  • Sort
  • Grouping groupby (sort first and then group) is
    not suitable for:
  • Few records
  • Frequently add, delete and modify
  • where not used
  • Poor filtering (gender)

Guess you like

Origin blog.csdn.net/qq_43430273/article/details/112976904