索引的种类

一、索引的特征

1、usability【可用性】

如果该索引为unusable,则优化器会忽略该索引,允许bulk load操作,不允许DML操作,同时ORACLE数据库会删除该索引所拥有的段。若要其可用,只需要rebuilt即可;

2、visibility【有效性】

如果该索引为invisible,则优化器会忽略该索引,允许DML操作。该设置主要用于索引删除前的测试或在不影响其他应用的前提下临时使用该索引。

二、索引的种类

1、B-tree索引

1.1 Index-organized tables:采用B-tree结构,把行数据保存在leaf block中的结构;

1.2 Reverse key indexes:逆转索引键的存储顺序;

1.3 Descending indexes:索引键按照降序来存储;

1.4 B-tree cluster indexes:采用B-tree结构对聚集键建立索引;

2、位图索引

3、基于函数的索引

4、Application domain indexes

1、B-tree索引:


B-tree索引是平衡的,因为所有的leaf block都在相同的深度上。为此,查询任何记录都会花费相同的时间。同时,从上图可以看出对于每个leaf block除了最开始的第一个和最后一个,其余的都是双向的。

1.1、Index-organized tables见博文:http://blog.csdn.net/flighting_sky/article/details/8868387

1.2、Reverse key indexes

假设有一个表A,A上的列b上建有索引B,b是按照升序排序的,则若在正常情况下其索引B上的leaf block上的索引键也是升序的,索引键和列b都是连续对应的。而采用了Reverse key indexes的方式组织后,A表中的b列还是连续存放,但是索引B的leaf block上的索引键却由于反向键而变得分散。当插入一个新的数据时,正常情况下所对应的索引键都会被插入到最右边的leaf block里面,而现在则会被分散插入到不同的leaf block中。从而避免了并发操作和RAC环境下对于最右边或最高leaf block的争用问题。
不足的是:
所读取的数据块,也就是物理读取将会增加;同时,由于物理上连续的行所对应的索引键在索引中并不是连续,而是分布在不同的leaf block中的。故不能使用range scan。

1.3、Descending indexes
对于经常升序或降序排序的字段采用相同的方式来组织索引可以加快检索的速度。

1.4、B-tree cluster indexes见博文:http://blog.csdn.net/flighting_sky/article/details/8860274

2、位图索引 见博文:http://blog.csdn.net/flighting_sky/article/details/8868402

3、基于函数的索引

把一个表的对于列数据的运算结果保存在索引中,当下次使用相同的运算的时候,就会通过查询该基于函数的索引来查找结果。基于函数的索引,可以弥补由于数据库设计所带来的问题。基于函数的索引采用的也是B-tree,只是leaf block保存的数据为:运算式结果+。。+ROWID;实质上,基于函数的索引是通过空间换时间,保存运算表达式的结果,从而节省CPU运算时间。

优化器通过比较SQL语句中的expression和function-based index中的expression进行比较,该比较忽略大小写的区别,忽略空格。如果相同,则优化器会采用该基于函数的索引,而不会重新计算。

实例:CREATE INDEX emp_total_sal_idx
ON employees (12 * salary * commission_pct , salary, commission_pct);

4、Application domain indexes

对于Application domain indexes,下面只是摘录ORACLE技术文档的话来简单介绍:

An application domain index is a customized index specific to an application. Oracle Database provides extensible indexing to do the following:
■ Accommodate indexes on customized, comp lex data types such as documents, spatial data, images, and video clips

■ Make use of specialized indexing techniques
You can encapsulate application-specific index management routines as an indextype schema object and define a domain index on table columns or attributes of an object type. Extensible indexing can efficiently process application-specific operators.The application software, called the cartridge, controls the structure and content of a domainindex. The database interacts with the application to build, maintain, and search the domain index. The index structure itself can be stored in the database as an index-organized table or externally as a file.


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值