如何理解concepts中关于index结构图描述的一段话?

[复制链接]
查看11 | 回复2 | 2008-9-24 01:04:18 | 显示全部楼层 |阅读模式
The Internal Structure of Indexes
Oracle uses B-trees to store indexes to speed up data access. With no indexes, you
have to do a sequential scan on the data to find a value. For n rows, the average
number of rows searched is n/2. This does not scale very well as data volumes
increase.
Consider an ordered list of the values divided into block-wide ranges (leaf blocks).
The end points of the ranges along with pointers to the blocks can be stored in a
search tree and a value in log(n) time for n entries could be found. This is the basic
principle behind Oracle indexes.
Figure 5–7 illustrates the structure of a B-tree index.
感觉上面标红的部分,理解起来有点麻烦.
字段意思似乎是这样:
1, 每个leaf block的end point(块末尾的指针),连同该指针指向的数据块,能够存储到搜索树中.
搜索树是什么?
这个表述想要表达一个什么意思呢?
2, 如果要在n个 index entry中搜索一个key value(暂不考虑是unique index还是nonuniqe index),
消耗的时间量级是 log(n), 这比全表扫描平均 n/2 性能要好.
有没有大虾能用通俗易懂的话解释一下呀,谢谢先!
[ 本帖最后由 tengrid 于 2008-9-24 19:42 编辑 ]
回复

使用道具 举报

千问 | 2008-9-24 01:04:18 | 显示全部楼层
Oracle 使用平衡树(B-tree)存储索引以便提升数据访问速度。当不使用索引时,用户必须对数据进行顺序扫描(sequential scan)来查找指定的值。如果有 n 行数据,那么平均需要扫描的行为 n/2。因此当数据量增长时,这种方法的开销将显著增长。
如果将一个已排序的值列(list of the values)划分为多个区间(range),每个区间的末尾包含指向下个区间的指针(pointer),而搜索树(search tree)中则保存指向每个区间的指针。此时在 n 行数据中查询一个值所需的时间为 log(n)。这就是 Oracle 索引的基本原理。
回复

使用道具 举报

千问 | 2008-9-24 01:04:18 | 显示全部楼层
谢谢xiaodong.
block-wide rang,意思是指 每个index block中会包含多个key value+rowid对, 所以可认为一个块是个范围,块之间是双向有序链表,这种结构本身有利于搜索. 是不是直接理解就ok了,没别的意思,呵呵.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则