SQL Server中的索引查找与索引扫描

时间:2020-12-22 02:48:35

Please explain the difference between Index Scan and Index Seek in MS SQL server with an sample example, since it will be helpful to know, what's the real use of it. Thanks in advance.

请通过示例说明MS SQL服务器中的索引扫描和索引查找之间的区别,因为了解它的实际用途会有所帮助。提前致谢。

2 个解决方案

#1


18  

Here is the text showplan (slightly edited for brevity) for this query using a scan:

以下是使用扫描进行此查询的文本showplan(为了简洁而略微编辑):

|–Table Scan(OBJECT:([ORDERS]), WHERE:([ORDERKEY]=(2)))

The following figure illustrates the scan:

下图说明了扫描:

SQL Server中的索引查找与索引扫描

Here is the text showplan for the same query using a seek:

以下是使用搜索的同一查询的文本showplan:

 |–Index Seek(OBJECT:([ORDERS].[OKEY_IDX]), SEEK:([ORDERKEY]=(2)) ORDERED FORWARD)

SQL Server中的索引查找与索引扫描

have a look on this SQL Server Plans : difference between Index Scan / Index Seek

看看这个SQL Server计划:Index Scan / Index Seek之间的区别

#2


4  

In simple words, An index scan or table scan is when SQL Server has to scan the data or index pages to find the appropriate records. A scan is the opposite of a seek, where a seek uses the index to pinpoint the records that are needed to satisfy the query.

简单来说,索引扫描或表扫描是指SQL Server必须扫描数据或索引页以查找相应的记录。扫描与搜索相反,其中搜索使用索引来精确定位满足查询所需的记录。

your question is similar to the question which is already posted in * get it from below link

你的问题类似于已经在*中发布的问题从下面的链接获取它

#Index scan vs Index seek

#Index扫描与索引搜索

you can also get information from below link

您也可以从以下链接获取信息

#Index scan vs Index seek in brief

#Index scan vs Index寻求简要介绍

#1


18  

Here is the text showplan (slightly edited for brevity) for this query using a scan:

以下是使用扫描进行此查询的文本showplan(为了简洁而略微编辑):

|–Table Scan(OBJECT:([ORDERS]), WHERE:([ORDERKEY]=(2)))

The following figure illustrates the scan:

下图说明了扫描:

SQL Server中的索引查找与索引扫描

Here is the text showplan for the same query using a seek:

以下是使用搜索的同一查询的文本showplan:

 |–Index Seek(OBJECT:([ORDERS].[OKEY_IDX]), SEEK:([ORDERKEY]=(2)) ORDERED FORWARD)

SQL Server中的索引查找与索引扫描

have a look on this SQL Server Plans : difference between Index Scan / Index Seek

看看这个SQL Server计划:Index Scan / Index Seek之间的区别

#2


4  

In simple words, An index scan or table scan is when SQL Server has to scan the data or index pages to find the appropriate records. A scan is the opposite of a seek, where a seek uses the index to pinpoint the records that are needed to satisfy the query.

简单来说,索引扫描或表扫描是指SQL Server必须扫描数据或索引页以查找相应的记录。扫描与搜索相反,其中搜索使用索引来精确定位满足查询所需的记录。

your question is similar to the question which is already posted in * get it from below link

你的问题类似于已经在*中发布的问题从下面的链接获取它

#Index scan vs Index seek

#Index扫描与索引搜索

you can also get information from below link

您也可以从以下链接获取信息

#Index scan vs Index seek in brief

#Index scan vs Index寻求简要介绍