What is an index?

后端 未结 7 1940
無奈伤痛
無奈伤痛 2020-12-15 06:42

What is an index in MySQL ????

7条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 07:33

    If you know that everyone has a unique social security number (SSN), then you could create an index of everyone's name, ordered by SSN. Then, if you were given someone's SSN, it would be really quick to find their name.

    Now assume that you have a manilla folder for each person. The card may have detailed medical records etc. Your database may not keep these cards in order - maybe it just adds new folders to the end of the compactus. But it keeps a sorted "index" so that if you look up an SSN, it can tell you exactly where the relevant folder is kept.

    In this example, the SSN is being used as a Primary Key. It's nice if it's unique, but even if it isn't unique, it can still speed things up.

提交回复
热议问题