SQL中的表扫描和索引扫描 [英] Table Scan and Index Scan in SQL

查看:102
本文介绍了SQL中的表扫描和索引扫描的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

SQL中的表扫描和索引扫描之间的区别是什么?具体用途是什么?

What is the difference between Table scan and Index scan in SQL and where it is used specifically?

推荐答案

表扫描的含义

索引扫描意味着遍历所有索引项,当项索引满足搜索条件时,将通过索引检索表行。

Index scan means iterate over all index items, when item index meets search condition, table row is retrived through index.

通常,索引扫描比表扫描便宜,因为索引比表更平坦。

Usualy index scan is less expensive than a table scan because index is more flat than a table.

关于这个问题,他们的书目很多。示例:

They are lot of bibliografy about this issue. Sample:

  • Microsoft: Which is Faster: Index Access or Table Scan?:

索引访问是一种访问方法,其中SQL Server使用现有的
索引来读取和写入数据页。因为索引访问
大大减少了I / O读取操作的次数,所以它通常胜过
表扫描。

Index access is an access method in which SQL Server uses an existing index to read and write data pages. Because index access significantly reduces the number of I/O read operations, it often outperforms a table scan.




  • Oracle:查询优化器

    • Oracle: The Query Optimizer

    • 在这种方法中,使用
      索引列值通过遍历索引来检索行声明中指定的内容。索引扫描
      基于索引中一个或多个列
      的值从索引中检索数据。为了执行索引扫描,Oracle在索引中搜索
      语句访问的索引列值。如果语句
      仅访问索引的列,那么Oracle直接从索引而不是从表中读取索引的
      列值。

      In this method, a row is retrieved by traversing the index, using the indexed column values specified by the statement. An index scan retrieves data from an index based on the value of one or more columns in the index. To perform an index scan, Oracle searches the index for the indexed column values accessed by the statement. If the statement accesses only columns of the index, then Oracle reads the indexed column values directly from the index, rather than from the table.




      • MySql:如何避免表格扫描

        • MySql: How to Avoid Table Scans
        • 这篇关于SQL中的表扫描和索引扫描的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆