在利用 SQL Server 查询分析器的执行计划中,会有许多扫描方式,其中就有 Clustered Index Scan 与 Clustered Index Seek,这二者有什么区别呢?

Clustered Index,为聚集索引,表示它们使用的都是聚集索引扫描。

Scan 表示它扫描一个范围或者是全部内容,Seek 表示扫描特定范围内的行。也就是说 Scan 并不知道要目标行是哪些,而 Seek 扫描表明我已经知道我要找的目标行是哪些,所以 Seek 一般要快些。

看看下面的语句,哪个(些)是 Scan 扫描,哪些是 Seek 扫描呢?

use master go select * from sysobjects select * from sysobjects where name like 'sys%' select * from sysobjects where id<3

由于 sysobjects 表是对 id 建的聚集索引,所以前两个查询语句使用的是 Scan,后面一个使用的是 Seek。

Clustered Index Scan 与 Clustered Index Seek Clustered Index Scan 与 Clustered Index Seek 的图标

相关文章:

  • 2021-10-12
  • 2022-01-22
  • 2022-12-23
  • 2021-12-08
  • 2022-12-23
  • 2021-07-12
猜你喜欢
  • 2021-10-02
  • 2022-03-03
  • 2022-02-13
  • 2022-12-23
相关资源
相似解决方案