reference:  http://docs.oracle.com/cd/B28359_01/server.111/b28318/schema.htm#CHDJGADJ

  当创建索引的时候,Oracle 会自动在表空间中分配一个索引段来存储索引数据。你可以控制索引段的空间分配并且通过以下两种方式对这部分保留空间进行使用:

  • 通过为索引段设置存储参数来控制索引段空间的分配范围。
  • 通过为索引段设置 PCTFREE 参数来控制组成索引段范围中的空闲空间。

The section includes the following topics:

  • Format of Index Blocks
  • The Internal Structure of Indexes
  • Index Properties
  • Advantages of B-tree Structure

Format of Index Blocks

索引数据的空用空间大小为 Oracle Database block size - block overhead, entry overhead, rowid and one length byte for each value indexed.

当你创建一个索引的时候,Oracle Database 获取被索引的数据列,并对它们进行排序,然后根据每行的索引值对rowid进行存储。然后Oracle Database 自底向上对索引进行加载。例如:

CREATE INDEX employees_last_name ON employees(last_name);

Oracle 根据last_name对表 employees 进行排序,然后按顺序加载由 last_name 和相应的rowid组成的索引。当使用索引的时候,Oracle对有序的 last_name 做一次快速查询,然后使用相关联的 rowid 的值去定位含有last_name值的所有行。

The Internal Structure of Indexes

Oracle 使用 B-trees 存储索引来加速数据访问。如果没有索引,你必须通过对数据进行 sequential scan 来找到目标值。在 n 行中进行查找,平均搜索的行数为 n/2。当数据量增加时,这种方式是很不合适的。

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 Database indexes.

Figure 5-7 illustrates the structure of a B-tree index.

Figure 5-7 Internal Structure of a B-tree Index

The upper blocks (branch blocks) of a B-tree index contain index data that points to lower-level index blocks. The lowest level index blocks (leaf blocks) contain every indexed data value and a corresponding rowid used to locate the actual row. The leaf blocks are doubly linked. Indexes in columns containing character data are based on the binary values of the characters in the database character set.

For a unique index, one rowid exists for each data value. For a nonunique index, the rowid is included in the key in sorted order, so nonunique indexes are sorted by the index key and rowid. Key values containing all nulls are not indexed, except for cluster indexes. Two rows can both contain all nulls without violating a unique index.

Index Properties

The two kinds of blocks:

  • Branch blocks for searching

  • Leaf blocks that store the values

Branch Blocks

Branch blocks store the following:

  • The minimum key prefix needed to make a branching decision between two keys

  • The pointer to the child block containing the key

If the blocks have n keys then they have n+1 pointers. The number of keys and pointers is limited by the block size.

Leaf Blocks

All leaf blocks are at the same depth from the root branch block. Leaf blocks store the following:

  • The complete key value for every row

  • ROWIDs of the table rows

All key and ROWID pairs are linked to their left and right siblings. They are sorted by (key, ROWID).

Advantages of B-tree Structure

The B-tree structure has the following advantages:

  • All leaf blocks of the tree are at the same depth, so retrieval of any record from anywhere in the index takes approximately the same amount of time.

  • B-tree indexes automatically stay balanced.

  • All blocks of the B-tree are three-quarters full on the average.

  • B-trees provide excellent retrieval performance for a wide range of queries, including exact match and range searches.

  • Inserts, updates, and deletes are efficient, maintaining key order for fast retrieval.

  • B-tree performance is good for both small and large tables and does not degrade as the size of a table grows.

How Indexes Are Stored的更多相关文章

  1. How does database indexing work?

    When data is stored on disk based storage devices, it is stored as blocks of data. These blocks are ...

  2. ocp 1Z0-042 1-60题解析

    1. Because of a power outage,instance failure has occurred. From what point in the redo log does rec ...

  3. 13.1.17 CREATE TABLE Syntax

    13.1.17 CREATE TABLE Syntax 13.1.17.1 CREATE TABLE ... LIKE Syntax 13.1.17.2 CREATE TABLE ... SELECT ...

  4. 翻译:Identifier Name标识符命名规则

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...

  5. Migrating Oracle on UNIX to SQL Server on Windows

    Appendices Published: April 27, 2005 On This Page Appendix A: SQL Server for Oracle Professionals Ap ...

  6. Programmer Competency Matrix--ref--http://sijinjoseph.com/programmer-competency-matrix/

    Note that the knowledge for each level is cumulative; being atlevel n implies that you also know eve ...

  7. MySQL表的碎片整理和空间回收小结

    MySQL表碎片化(Table Fragmentation)的原因 关于MySQL中表碎片化(Table Fragmentation)产生的原因,简单总结一下,MySQL Engine不同,碎片化的原 ...

  8. MySQL 5.6 Reference Manual-14.5 InnoDB Tablespace Management

    14.5 InnoDB Tablespace Management   14.5.1 Resizing the InnoDB System Tablespace 14.5.2 Changing the ...

  9. MySQL 5.6 Reference Manual-14.1 Introduction to InnoDB

    14.1 Introduction to InnoDB 14.1.1 InnoDB as the Default MySQL Storage Engine 14.1.2 Checking InnoDB ...

随机推荐

  1. 【转】 hive简介,安装 配置常见问题和例子

    原文来自:  http://blog.csdn.net/zhumin726/article/details/8027802 1 HIVE概述 Hive是基于Hadoop的一个数据仓库工具,可以将结构化 ...

  2. MBProgressHUD not showing

    In my app, I am loading a resource heavy view that takes about 1 to 2 seconds to load. So I am loadi ...

  3. [OC Foundation框架 - 22] 集合的内存管理

    A.集合的手动内存管理 NSArray addObject: 加入的元素执行一次retain removeObject: 被删除的元素执行一次release removeAllObjects: 所有元 ...

  4. 剑指OFFER之把数组排成最小的数(九度OJ1504)

    题目描述: 输入一个正整数数组,把数组里所有数字拼接起来排成一个数,打印能拼接出的所有数字中最小的一个.例如输入数组{3,32,321},则打印出这三个数字能排成的最小数字为321323. 输入: 输 ...

  5. python会什么比c慢

    众所周知,python执行速度比c慢.原因为何? 先来看下面这张图: python的传统运行执行模式:录入的源代码转换为字节码,之后字节码在python虚拟机中运行.代码自动被编译,之后再解释成机器码 ...

  6. 理解virtual方法

    1.使用场景 virtual方法的使用场景:父类告诉子类,继承接口,修改实现,从而可以面向接口编程. non-virtual方法的使用场景:父类告诉子类,继承接口和实现,从而可以代码复用. 2.成员方 ...

  7. KeyTweak 键盘按键功能修改

    最近一致再用ThinkPad S3,悲剧的是上翻页和下翻页竟然和方向键在一起,经常按错光标不知道去哪里了. 实在忍受不了,竟然有这样的软件,哈哈. KeyTweak,用起来太方便了

  8. 什么是集群(cluster)

    1.集群 1.1 什么是集群 简单的说,集群(cluster)就是一组计算机,它们作为一个总体向用户提供一组网络资源.这些单个的计算机系统就是集群的节点(node).一个理想的集群是,用户从来不会意识 ...

  9. delphi中使用webbrowser提交表单

    转自:http://blog.163.com/hehaifeng1984@126/blog/static/6900113620133504644998/ 我们以百度搜索为例,使用webbrowser组 ...

  10. (转)Dependency Walker使用说明

    在Windows世界中,有无数块活动的大陆,它们都有一个共同的名字——动态链接库.现在就让我们走进这些神奇的活动大陆,找出它们隐藏已久的秘密吧! 初窥门径:Windows的基石 随便打开一个系统目录, ...