Structure description [Posts] B-tree indexes and bitmap index

B-tree index and bitmap index structure described

http://blog.itpub.net/12679300/viewspace-1174236/

 

A preface:?  ROWID : row ID of the row that contains the key value, ( look for the fastest way to block similar house number ) because all rows belong to the same segment, so use a restricted ROWID point table row?

The index is a database query in order to improve efficiency over a redundant configuration provided, a conservative calculation of 50% or more of the database tuning can be optimized by adjusting the index;

ORACLE domestic quoted a senior expert of the words: "Actually, I only know how to point (kicked) knowledge, IT but in fact only know how to point to Oracle, Oracle database which in fact only know how to point, but in fact only know how to spot a database SQL, SQL but in fact only understand the point of the index "-" you are the real experts "!

According shallow personal experience as a DBA's daily operation and maintenance will be less and less, from every point of view version of the database update, database systems have tended more and more intelligent then, DBA less and less capable of living up If a DBA can only be doing the daily table space expansion, updating database backup recovery, start and stop the system, it would be a very dangerous thing. The tune has historically been a very deep knowledge, if we can do this, then the DBA can create value and role in the company, the more significant;

Having said that, should the introduction of the theme, if you want to do a good job tuning, starting with the index to start it.

Subsequent chapters will continue to update some knowledge of the index, the index category from the first chapter started;

 

Two categories on the index structure may be divided as follows: B-tree indexes, bitmap indexes, hash indexes, etc. inverted index

 

Three index Introduction:

1, B-tree index (BTREE

B index is the number of our daily work most commonly used index, we usually work, said the "index" default index number is B;

The index is actually very simple, and very easy to understand, with a catalog of a book to describe the most appropriate structure with the library's catalog B-tree index also like

B-tree index structure:

Index top of the root, which includes links to the next level of the index entry. The next level is a branch block it in the index points to the next level in the one index block, the bottom is the leaf node that contains the index entry points to table rows. Leaf blocks is bidirectional associated here with the key values ​​in ascending or descending scan index;

 

Format of index leaf entry

An index entry contains the following components:

? Head entries: the number of columns and lock information storage

? Column length key / value pairs: a column for size defined keys, followed by the column value (the number of columns in the index is the maximum number of such length / value pairs).

 

Index leaf entry characteristics

B-tree index in the non-partitioned table:

? When multiple rows with the same key, if not the compression index, the key will repeat

? When a row contains all the key as NULL, the bank has no corresponding index entries. Therefore, when the WHERE clause specifies NULL, will always perform a full table scan

 

The index to perform DML  effect operations

When DML operations on a table, Oracle server maintains all the indexes. The following describes the effect of the implementation of DML commands generated by the index:

? Insert operation result in the insertion of index entries in the respective block.

? Delete a row only lead to the index entries tombstone. Deleted rows occupied space is not available for new leaf entry later use.

? Update the index key columns result in a logical delete and insert. PCTFREE setting has no effect on the index, except when created. Even if the space is less than the index block PCTFREE specified space, or add new entries to the index block.

FIG better reflect the structure of the index

 

2, a bitmap index

Bitmap indexes (bitmap index) is introduced from the start Oracle7.3 version. Currently Oracle Enterprise Edition and Personal Edition supports bitmap indexes, but the standard version is not supported.

Bitmap index is relatively rare in the usual OLTP system, but will often seen in OLAP system, one of the three data warehouse tool called tuning;

 

 

 

Bitmap index (in the following by specific circumstances, a bitmap index than the B-tree index advantage:

(That is, different values ​​of the column very little time) when a low base? Table with millions of rows and columns of keys. For example, for a passport record table columns marital status and gender, a bitmap index may be more preferable than the B-tree index.

When? Queries often comprise a combination of a plurality of OR WHERE condition operators

? 键列上的活动为只读活动或少量更新活动时(OLAP系统的特点)

 

位图索引的结构

位图索引也可以按B 树形式进行组织,但是,叶节点会存储每个键值的位图,而不是行ID 列表。位图中每一位与一个可能的行ID 对应,如果设置了该位,则表示具有对应行ID 的行包含键值。

如图所示,位图索引的叶节点包含:

? 条目头,其中包含列数和锁定信息

? 由每个键列的长度/值对组成的键值(在幻灯片的示例中,关键字只由一列组成;第一个条目的键值为Blue)

? 开始ROWID,在本示例中它指定块号10、行号0 和文件号3

? 结束ROWID,在本示例中它指定块号12、行号8 和文件号3

? 由位字符串组成的位图段(如果对应行包含键值,则会设置位;如果对应行不包含键值,则不会设置位。Oracle 服务器使用已获专利的压缩技术存储位图段。)开始ROWID 是位图中的位图段指向的第一行的行ID,也就是说,位图的第一位对应于该行ID,位图的第二位对应于块中的下一行。结束ROWID 是一个指针,它指向由位图段覆盖的表中的最后一行。位图索引使用受限的行ID。

 

使用位图索引

B 树用于定位叶节点,这些节点包含指定键值的位图段。开始ROWID 和位图段用于定位包含键值的行。

对表中的键列进行更改后,也必须修改位图。这会导致相关的位图段被锁定。由于锁是在整个位图段上获得的,因此,在第一个事务处理结束之前,其它事务处理不能更新位图覆盖的行。

 

 

文档的篇幅有限,先介绍最常见的B树索引和位图索引,这只是入门的第一步,后续将会陆续更新,多谢各位的关注。

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

本文作者:JOHN

ORACLE技术博客:ORACLE 猎人笔记               数据库技术群:367875324 (请备注ORACLE管理 )  

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Guess you like

Origin www.cnblogs.com/jinanxiaolaohu/p/11840392.html