我有一个查询并检查SQL Management Studio中的执行计划.某些非聚集索引扫描步骤将返回表的PK列,而不是索引和连接列.例:
select a.c10, b.c20
from a inner join b on a.c11 = b.c21
where a.c12 = 23
Run Code Online (Sandbox Code Playgroud)
表a上的索引:
create unique nonclustered index ix_a_1 on a (a.c12 asc) include ( a.c13, a.c14)
Run Code Online (Sandbox Code Playgroud)
查询计划显示:
index seek, nonclustered, ix_a_1 , output list: a.primary_key_col
Run Code Online (Sandbox Code Playgroud)
查询中未使用a.primary_key_col列.为什么这是输出列表中包含的唯一列?