IOT表
以前在接触索引的时候,就想过要是表字段太少,索引效果不是很不好吗,直接用索引不是更直接吗?后来因为懒惰也没有去查找相关资料。正好今天看到了table organization index,看了一下,实现的功能就是这个意思,这里分享给大家。
其实正常项目中,90%以上都是正常的heap表。但我们也不能忽略那些用的少,但给我们性能带来巨大优化的其他表类型。
首先,创建两张表:
create table tindex
(myid number primary key,
myname varchar2(20))
organization index;
create table tindex1
(myid number primary key,
myname varchar2(20)) ;
分别插入数据
insert into tindex values(111,'abcd');
insert into tindex1 values(111,'abcd');
1、我们来看没有where解释计划:
select * from tindex;
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)|Time |
------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 2 (0)|00:00:01 |
| 1 | INDEX FAST FULL SCAN| SYS_IOT_TOP_92809 | 1 | 25 | 2 (0)|00:00:01 |
------------------------------------------------------------------------------------------
Note
------ dynamic sampling used for this statement (level=2)
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
4 consistent gets
0 physical reads
0 redo size
491 bytes sent via SQL*Net to client
420 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
select * from tindex1;
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 3 (0)| 00:00:01 |
| 1 | TABLE ACCESS FULL| TINDEX1 | 1 | 25 | 3 (0)| 00:00:01 |
-----------------------------------------------------------------------------
Note
------ dynamic sampling used for this statement (level=2)
统计信息
----------------------------------------------------------
0 recursive calls
0 db block gets
7 consistent gets
0 physical reads
0 redo size
495 bytes sent via SQL*Net to client
419 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
可以看到consistent gets相差2,通过解释计划,一个为INDEX FAST FULL SCAN,另一个是INDEX FAST FULL SCAN,相信我们也可以看出其中的原因。因为一个是按照物理顺序来读取。
2、在我们加上条件where后,效果更加明显:
select * from tindex where myid=111;
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Tim
e |
---------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 25 | 1 (0)| 00:
00:01 |
|* 1 | INDEX UNIQUE SCAN| SYS_IOT_TOP_92809 | 1 | 25 | 1 (0)| 00:
00:01 |
select * from tindex1 where myid=111;
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)
| Time |
--------------------------------------------------------------------------------
------------
| 0 | SELECT STATEMENT | | 1 | 25 | 1 (0)
| 00:00:01 |
| 1 | TABLE ACCESS BY INDEX ROWID| TINDEX1 | 1 | 25 | 1 (0)
| 00:00:01 |
|* 2 | INDEX UNIQUE SCAN | SYS_C0015919 | 1 | | 1 (0)
| 00:00:01 |
其中一个consistent gets为1,另一个为2,原因从解释计划的执行方式可以看出,一个需要返回给heap表,另一个则不需要。
IOT表的更多相关文章
- dump iot表
SQL> create user scan identified by scan default tablespace users; User created. SQL> grant db ...
- iot 表 主键索引叶子块包含了表所有数据
<pre name="code" class="html">iot表测试: 在create table语句后面使用organization inde ...
- iot 表索引dump《2》
iot表测试: 在create table语句后面使用organization index,就指定数据表创建结构是IOT.但是在不指定主键Primary Key的情况下,是不允许建表的. create ...
- heap表和iot表排序规则不同
heap 和iot 对比 OBJECT_NAME OBJECT_TYPE --------------------------------------------------------------- ...
- iot表输出按主键列排序,heap表不是
<pre name="code" class="html"> create table t1 (id char(10) primary key,a1 ...
- iot 表主键存放所有数据,且按数据插入顺序排序
iot表测试: 在create table语句后面使用organization index,就指定数据表创建结构是IOT.但是在不指定主键Primary Key的情况下,是不允许建表的. create ...
- Mysql InnoDB 是IOT表 锁基于索引
</pre>Mysql InnoDB 是IOT表 锁基于索引<pre>
- Oracle 验证IOT表数据存储在主键里
iot表测试: 在create table语句后面使用organization index,就指定数据表创建结构是IOT.但是在不指定主键Primary Key的情况下,是不允许建表的. create ...
- IOT表优缺点
<pre name="code" class="html">IOT表是将所有东西都塞到叶块中,表就是索引,可以避免回表 首先,对于IOT而言,只有索 ...
- Mysql iot表
我们知道一般的表都以堆(heap)的形式来组织的,这是无序的组织方式. Oracle还提供了一种有序的表,它就是索引组织表,简称IOT表.IOT表上必须要有主键,而IOT表本身不对应segment,表 ...
随机推荐
- 【FFT】hdu1402 A * B Problem Plus
FFT板子. 将大整数看作多项式,它们的乘积即多项式的乘积在x=10处的取值. #include<cstdio> #include<cmath> #include<cst ...
- 【深度搜索+剪枝】POJ1011-Sticks
深搜部分和之前的POJ2362差不多,只是有几处需要额外的剪枝. [思路]排序后从最短木棒开始搜索至木棒长总和,如果木棒长总和sum能整除当前棒长,则进入深搜. [剪枝]先前POJ2362的剪枝部分不 ...
- (转)CString,int,string,char*之间的转换
CString,int,string,char*之间的转换http://www.cnblogs.com/greatverve/archive/2010/11/10/cstring-int-string ...
- 转:Oracle密码过期,取消密码180天限制
原文:https://www.cnblogs.com/soar-gh/p/5949158.html 1.进入sqlplus模式 sqlplus / as sysdba; 2.查看用户密码的有效期设置( ...
- Netty游戏服务器二
上节我们写个server主类,那么发现什么事情都干不了,是的,我们还没有做任何的业务处理. 接着我们开始写处理客户端连接,发送接收数据的类ServerHandler. public class Ser ...
- OpenShift helm的安装
1.安装过程 下载addons的代码 $ git clone https://github.com/jorgemoralespou/minishift-addons $ cd minishift-ad ...
- 预防U盘被病毒侵害的方法
写在前面:此方法只能杜绝自己的u盘免收侵害,而不能杜绝自己的电脑免收其他u盘病毒的侵害,如果想知道如何让自己的电脑防止被u盘病毒侵害,可以阅读此文章:https://www.cnblogs.com/t ...
- 在Eclipse中点击ctrl+h打开搜索界面,范围指定的项目中搜索包含person的文件
ctrl+h ===>File Search Tab ===>在containing text里输入person,scope ==>selected resources,搜索就可以了
- Rails零散知识
1. 邮箱验证VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i validates :email, pres ...
- 常用class 总结
清除浮动 // Clearfix @mixin clearfix { &:before, &:after { content: " "; // 1 display: ...