The Internal Structure of Indexes (208)
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.
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.
索引的內部結構
1. Oracle 索引的基本原理 : 如果將一個已排序的值列劃分為以塊為單位的區間,每個區間的末尾包含
指向下個區間的指標,而搜尋樹中則儲存指向每個區間的指標。此時在 n 行資料中查詢一個值所需的時間為
log(n)。
2. B樹索引的分支塊包含了指向下層索引塊的指標 ,葉子塊包含了被索引的資料值,以及對應的 rowid 。
葉子節點以雙向列表形式連線
3. 對於唯一索引 ,每個索引值對應著唯一的一個 rowid。對於非唯一索引,每個索引值
對應著多個已排序的 rowid。因此在非唯一索引中,索引資料是按照索引鍵及 rowid 共同排序的。
鍵值全部為 NULL 的行不會被索引,只有簇索引例外。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10599713/viewspace-982565/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 翻譯(九)——Clustered Indexes: Stairway to SQL Server Indexes Level 3IndexAISQLServer
- data structureStruct
- PHP-leetcode-208PHPLeetCode
- VulNyx - Internal
- [20180510]20 Indexes.txtIndex
- OpenAPI Basic StructureAPIStruct
- PostgreSQL DBA(45) - Hypothetical Indexes in PostgreSQLSQLIndex
- Data Structure_樹Struct
- sqrt-data-structureStruct
- idea--Project StructureIdeaProjectStruct
- AT_abc208_d 題解
- CF208E 題解
- MySQL 8 新特性之Invisible IndexesMySqlIndex
- SAP Spartacus Reference App StructureAPPStruct
- 1.2 Physiacel Structure of Database ClusterStructDatabase
- 1.1 Logical Structure of Database ClusterStructDatabase
- SGU 208 Toral Tickets(polay計數)
- [20202117]Function based indexes and cursor sharing.txtFunctionIndex
- Accessing Internal Members in the UNO FrameworkFramework
- Half-Edge-Mesh-Data-StructureStruct
- Composition and Structure of an INVOIC IDoc in SAP ERPStruct
- SAP ABAP Append structure 介紹APPStruct
- 208. 實現 Trie (字首樹)-pythonPython
- [20220414]Function based indexes and cursor sharing2.txtFunctionIndex
- How Oracle Store Number internal(zt)Oracle
- ORA-00600: [OSDEP_INTERNAL]
- Structure of Linux Kernel Device Driver(Part II)StructLinuxdev
- CH32V208基本介面函式函式
- Java 208 道面試題 · (八)網路Java面試題
- Java 208 道面試題 · (六)Java WebJava面試題Web
- PostgreSQL DBA(159) - pgAdmin(Allow vacuum command to process indexes in paralleSQLIndex
- Swift 3.0 的 open,public,internal,fiSwift
- DrawERD makes it easy to visualize your database structure.DatabaseStruct
- (乾貨)【intellij idea】Project Structure 講解IntelliJIdeaProjectStruct
- 什麼是 SAP ABAP 的 include structureStruct
- 208道面試題(JVM部分暫無答案)面試題JVM
- 惠普208/232/233國產硒鼓加粉影片
- 惠普208/232/233更換國產硒鼓影片
- Oracle 19c Concepts(03):Indexes and Index-Organized TablesOracleIndexZed