Home Database Mysql Tutorial Oracle 11g Release (11.1) 索引底层的数据结构

Oracle 11g Release (11.1) 索引底层的数据结构

Jun 07, 2016 pm 05:55 PM
oracle release

本文介绍关于 Oracle 索引的结构。大概了解 Oracle 索引底层的数据结构,从而更好地理解 Oracle 索引对增、删、改、查的性能

本文内容 B-树(B-tree) 散列(Hash) k-d 树(k-d tree) 点四叉树(Point Quadtree)

本文介绍关于 Oracle 索引的结构。大概了解 Oracle 索引底层的数据结构,从而更好地理解 Oracle 索引对增、删、改、查的性能。

B-树(B-tree)

非索引的结构能满足所有需要,但自平衡的 B-树索引结构更能优化在大数据集上检索的性能。每个 B-树节点拥有多个键和指针。特定 B-树支持的一个节点中键的最大数量是那颗树的顺序。每个节点都具有一个潜在的 order+1 指针,指向比它更低一级的节点。

例如,如图 1 所示,order=2 的 B-树具有三个指针,分别指向:比它第一个键小的子节点(最左边的指针);比它第一个键大,比第二个键小的子节点(中间的指针);比它第二个键大的子节点(最右边的指针)。因此,B-树算法,最大限度地减少定位记录所需的读写,通过传递比二叉树算法更少的节点,二叉树对每个确定的节点,用一个键和最多两个子节点(二叉树的结构是一个键值,左右两个指针,B-树是二叉树的扩展)。下图描述的是克努特变换(Knuth variation),它的索引由两部分组成:一个顺序集(Sequence set),提供快速顺序的访问数据;一个索引集(Index set),提供直接访问顺序集。

虽然,B-树的节点,一般不包含相同数量的数据值,并且他们通常包含一定量的未使用空间,B-树算法确保树保持平衡,和叶节点在同一级上。

图 1 B-树

散列(Hash)

散列根据一个给定字段值快速直接地访问一个特定的已存储的记录。每个记录被放置的位置是根据同一个函数,记录的一些字段域的函数计算的。并用相同的函数插入和更新。

散列的问题是记录的物理顺序与它们的逻辑顺序没有任何关系。另外,散列会在磁盘上存在大量未使用的区域。

图 2 散列

k-d 树(k-d tree)

具有两维的数据,例如经度和纬度,可用通过使用 k-d树变换,称为 2-d 树,被有效地存储和检索。

在这个结构,每个节点的数据类型,是字段信息,两个坐标,和指向两个子节点的左指针和右指针。

图 3 2-d 树

这种结构利于范围查询。也就是说,如果用户指定一个点(xx, xx)和一个距离,那么,查询会返回在这个指定的原来点距离内的所有点集合。

2-d 树很容易实现。但是因为,一个包含 k 个节点的 2-d 树具有 k 高度,因此,插入和查询复杂。

点四叉树(Point Quadtree)

点四叉树,在图 4 所示,也用来表示在一个两维空间中的点数据,但这些结构把区域划分为四个部分,而 2-d 树划分为两个。节点记录类型的字段由属性信息组成,包括两个坐标和指向四个子节点的方位点,按顺时针,如西北NW,西南SW,东北NE,东南SE。

图 4 Point Quadtree 索引结构

点四叉树跟 2-d 树一样也很容易实现。一个包含 k 个节点的四叉树具有 k 高度,插入和查询复杂。每个比较都要求在至少两个坐标上进行。然而,实际中,从 root 到 leaf 的长度在点四叉树中往往较短。

复制上面第二个链接里边提供的 Python 代码,做适当修改。因为,网页提供的代码只能运行在较低版本 Python。Python 3 之后的版本跟之前的差异较大。因此,下载本文最后源代码,并在 Python 3.3 的 IDLE 运行。会得到如下输出:

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:57:17) [MSC v.1600 64  (AMD64)]  win32
Copy after login
Type "copyright", "credits"  "license()"  more information.
Copy after login
>>> ================================ RESTART ================================
Copy after login
>>> 
Copy after login
<?xml version="1.0" encoding="iso-8859-1"?>
Copy after login
-
Copy after login
 "http:
Copy after login
<svg xmlns="http:
Copy after login
 <line x1="1" y1="1" x2="1" y2="399"></line>
Copy after login
 <line x1="1" y1="399" x2="399" y2="399"></line>
Copy after login
 <line x1="399" y1="399" x2="399" y2="1"></line>
Copy after login
 <line x1="399" y1="1" x2="1" y2="1"></line>
Copy after login
 <line x1="200" y1="1" x2="200" y2="399"></line>
Copy after login
 <line x1="1" y1="200" x2="399" y2="200"></line>
Copy after login
 <line x1="100" y1="1" x2="100" y2="200"></line>
Copy after login
 <line x1="1" y1="100" x2="200" y2="100"></line>
Copy after login
 <line x1="50" y1="1" x2="50" y2="100"></line>
Copy after login
……
Copy after login

复制输出的结果,命名为 .svg,.html 也行,用浏览器打开,会呈现下图:

图 5 一个 8*8 大小的点四叉树区域

看这个图,从左上角开始,顺时针。你可以当做“根据需要,是否要点,不断按 4 个分裂其中一个方块”。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How long will Oracle database logs be kept? How long will Oracle database logs be kept? May 10, 2024 am 03:27 AM

The retention period of Oracle database logs depends on the log type and configuration, including: Redo logs: determined by the maximum size configured with the "LOG_ARCHIVE_DEST" parameter. Archived redo logs: Determined by the maximum size configured by the "DB_RECOVERY_FILE_DEST_SIZE" parameter. Online redo logs: not archived, lost when the database is restarted, and the retention period is consistent with the instance running time. Audit log: Configured by the "AUDIT_TRAIL" parameter, retained for 30 days by default.

The order of the oracle database startup steps is The order of the oracle database startup steps is May 10, 2024 am 01:48 AM

The Oracle database startup sequence is: 1. Check the preconditions; 2. Start the listener; 3. Start the database instance; 4. Wait for the database to open; 5. Connect to the database; 6. Verify the database status; 7. Enable the service (if necessary ); 8. Test the connection.

Remote 3 universal remote control comes with touchscreen, but without subscription or server obligation Remote 3 universal remote control comes with touchscreen, but without subscription or server obligation Jun 14, 2024 am 09:13 AM

SincethedemiseofLogitech'spopularHarmonyremotecontrols,themarketforhigh-qualityuniversalremotecontrolshasbeenfragmentedatbest.UnfoldedCircleaimstoavoidthefateoftheHarmonyUltimatebyeliminatinganyserverobligationsorsubs

How much memory does oracle require? How much memory does oracle require? May 10, 2024 am 04:12 AM

The amount of memory required by Oracle depends on database size, activity level, and required performance level: for storing data buffers, index buffers, executing SQL statements, and managing the data dictionary cache. The exact amount is affected by database size, activity level, and required performance level. Best practices include setting the appropriate SGA size, sizing SGA components, using AMM, and monitoring memory usage.

How to see the number of occurrences of a certain character in Oracle How to see the number of occurrences of a certain character in Oracle May 09, 2024 pm 09:33 PM

To find the number of occurrences of a character in Oracle, perform the following steps: Get the total length of a string; Get the length of the substring in which a character occurs; Count the number of occurrences of a character by subtracting the substring length from the total length.

Oracle database server hardware configuration requirements Oracle database server hardware configuration requirements May 10, 2024 am 04:00 AM

Oracle database server hardware configuration requirements: Processor: multi-core, with a main frequency of at least 2.5 GHz. For large databases, 32 cores or more are recommended. Memory: At least 8GB for small databases, 16-64GB for medium sizes, up to 512GB or more for large databases or heavy workloads. Storage: SSD or NVMe disks, RAID arrays for redundancy and performance. Network: High-speed network (10GbE or higher), dedicated network card, low-latency network. Others: Stable power supply, redundant components, compatible operating system and software, heat dissipation and cooling system.

How to read dbf file in oracle How to read dbf file in oracle May 10, 2024 am 01:27 AM

Oracle can read dbf files through the following steps: create an external table and reference the dbf file; query the external table to retrieve data; import the data into the Oracle table.

How much memory is needed to use oracle database How much memory is needed to use oracle database May 10, 2024 am 03:42 AM

The amount of memory required for an Oracle database depends on the database size, workload type, and number of concurrent users. General recommendations: Small databases: 16-32 GB, Medium databases: 32-64 GB, Large databases: 64 GB or more. Other factors to consider include database version, memory optimization options, virtualization, and best practices (monitor memory usage, adjust allocations).

See all articles