Is it bad to have a non-clustered index that contains the primary key from the clustered index?

后端 未结 4 1674
长情又很酷
长情又很酷 2021-01-05 06:59

If you have a table with a clustered index on the Primary Key (int), is it redundant and bad to have one (ore more) non-clustered indexes that include that primary key colum

4条回答
  •  半阙折子戏
    2021-01-05 07:54

    There's no 100% answer, but the answer is almost definitely.

    The other indexes are there to assist in helping with joins and sorting (generally). Given that the primary key is already indexed, if the optimizer can join based on that it'll use that.

    If another index is needed from a join/sort perspective, what additional help does having the PK in the index mix provide? If it couldn't join based on the PK before, it's not going to now. And it's not really going to help any with sorting either.

提交回复
热议问题