Is there any benefit to creating and index on a primary key?

蹲街弑〆低调 提交于 2019-12-04 14:50:27

To your first question, yets, you're safe to assume that.

To the second question:

Indexes help to speed up searching - it's like an index in a book. They can help the DB engine jump to the correct record, just as an index can help you jump to the right page in a book.

The benefit to indexes that you might create youself depends on how you intend to search the data.

In your example, I'd create an INDEX on the name fields if you're going to search on them in your app.

If there's an index on PRIMARY_KEY, and an index on LastName, FirstName, that does not automatically mean an index on PRIMARY_KEY, LastName, FirstName.

However, in cases like this the primary key field is often redundant as you have a different index to work with.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!