我正在使用 EXPLAIN PLAN
在一个简单的 Oracle 数据库中 SELECT
声明只是为了了解它是如何工作的。
在 EXPLAIN PLAN
的一个输出中有提到table access by index rowid
另一个是 table access by index rowid BATCHED
.
它们之间有什么区别?
最佳答案
该文档仅包含有关此主题的一句话:
https://docs.oracle.com/database/121/TGSQL/tgsql_optop.htm#GUID-4180BA97-3E2C-41F9-B282-4FB3FF9532CB
The BATCHED access shown in Step 1 means that the database retrieves a few row ids from the index, and then attempts to access rows in block order to improve the clustering and reduce the number of times that the database must access a block.
考虑以下(简化的)索引示例
+-------------+------------------+
| index value | block nbr-rowid |
+-------------+------------------+
| 1 | 015-000123 |
| 2 | 034-000527 |
| 3 | 088-000285 |
| 4 | 015-000889 |
| 5 | 088-000632 |
........
........
在“正常”(非批处理)方法中,Oracle 按照索引确定的顺序检索行:
在批处理方法中,oracle 从索引中检索一些条目,然后首先按块数对它们进行排序,然后按照块数确定的顺序处理条目:
正如你在这个例子中看到的,块只被读取了 3 次而不是 5 次,所以从磁盘读取块的次数已经减少了 - 有些块只被读取了一次而不是两次(或更多次)。
关于oracle - 通过索引 rowid BATCHED 访问表和通过索引 rowid 访问表的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36957028/