How to use MySQL index columns?

后端 未结 5 578
广开言路
广开言路 2020-12-29 09:39

When do you use each MySQL index type?

  • PRIMARY - Primary key columns?
  • UNIQUE - Foreign keys?
  • INDEX - ??

For really large table

5条回答
  •  天涯浪人
    2020-12-29 10:28

    Indexes will improve performance on larger tables. Normally, the primary key has an index based on the key. Usually unique.

    It is useful to add indexes to fields that are used to search on a lot too such as Street Name or Surname as again it will improve perfomance. Don't need to be unique.

    Foreign Keys and Unique Keys are more for keeping your data integrity in order. So that you cannot have duplicate primary keys and so that your child tables don't have data for a parent that has been deleted.

提交回复
热议问题