oracle index的5种使用模式
来源:互联网 发布:mac硬件故障检测工具 编辑:程序博客网 时间:2024/05/29 06:28
索引的使用对数据库的性能有巨大的影响。
共有五类不同的使用模式。
1。INDEX UNIQUE SCAN 效率最高,主键或唯一索引
2。INDEX FULL SCAN 有顺序的输出,不能并行读索引
3。INDEX FAST FULL SCAN 读的最块,可以并行访问索引,但输出不按顺序
4。INDEX RANGE SCAN 给定的区间查询
5。INDEX SKIP SCAN 联合索引,不同值越少的列,越要放在前面
--实验后的总论。
能用唯一索引,一定用唯一索引
能加非空,就加非空约束
一定要统计表的信息,索引的信息,柱状图的信息。
联合索引的顺序不同,影响索引的选择,尽量将值少的放在前面
只有做到以上四点,数据库才会正确的选择执行计划。
conn system/manager
grant select any dictionary to scott;
conn scott/tiger
drop table t1 purge;
create table t1 as select * from dba_objects;
analyze table t1 compute statistics;
create index it1 on t1(object_type);
set autot traceonly
select distinct object_type from t1;
将是全表扫描,为什么不使用索引呢?因为索引中不能含有null值,
如果使用索引就可能产生不正确的结果。
--增加非空约束
alter table t1 modify (object_type not null);
select distinct object_type from t1 ;
使用INDEX FAST FULL SCAN方式查找数据
--
select object_type from t1;
使用INDEX FAST FULL SCAN,因为不需要排序
select object_type from t1 order by 1;
使用INDEX FULL SCAN,因为要按照顺序输出
select object_type from t1 where object_type='TABLE';
使用INDEX RANGE SCAN
--使用非唯一索引
create index i2t1 on t1(object_id);
select * from t1 where object_id=3762;
使用INDEX RANGE SCAN,因为数据库不知道是否唯一
--使用唯一索引
drop index i2t1;
create unique index i2t1 on t1(object_id);
使用INDEX UNIQUE SCAN,因为数据库知道是唯一的
--跳跃的扫描索引
create index i3t1 on t1(object_type,object_name);
select * from t1 where object_name='EMP';
select object_name from t1 where object_name='EMP';
使用INDEX SKIP SCAN,因为数据库知道可以跳过object_type,虽然object_name在第二个列。
--联合索引的顺序不同,影响索引的选择,尽量将值少的放在前面
drop index i3t1;
drop index it1;
create index i3t1 on t1(object_name,object_type);
select * from t1 where object_type='TABLE';
计划为全表扫描。
- oracle index的5种使用模式
- Oracle索引(Index)的使用
- oracle索引的5种使用模式
- oracle索引的5种使用模式
- Oracle的Index
- Oracle的Index
- Oracle 的 Index
- Oracle Index 的三個問題
- Oracle index 的运用
- Oracle的Index,以及组合Index
- Oracle索引(Index)创建使用
- Oracle索引(Index)创建使用
- Oracle索引(Index)创建使用
- Oracle索引(Index)创建使用
- Oracle索引(Index)创建使用
- Oracle索引(Index)创建使用
- Oracle执行计划——使用index full scan的几种情况
- Oracle索引表的使用(Table Index)
- 在Linux下安装JDK
- LVITEM
- container_of作用
- 用情感化交互为你的产品注入灵魂
- vc 调试
- oracle index的5种使用模式
- oracle Wallet配置
- What is \f ?
- 计算机图形学的学习方法介绍
- SDET系列课程第三部分(持续集成)圆满结束
- 分组报表新增指标指标类型不正确的话会导致
- SqlServer 分组自增ID设置
- VC 画一个圆形按钮
- 后台设置按钮禁止多次点击重复提交数据