以前在接触索引的时候,就想过要是表字段太少,索引效果不是很不好吗,直接用索引不是更直接吗?后来因为懒惰也没有去查找相关资料。正好今天看到了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表的更多相关文章

  1. dump iot表

    SQL> create user scan identified by scan default tablespace users; User created. SQL> grant db ...

  2. iot 表 主键索引叶子块包含了表所有数据

    <pre name="code" class="html">iot表测试: 在create table语句后面使用organization inde ...

  3. iot 表索引dump《2》

    iot表测试: 在create table语句后面使用organization index,就指定数据表创建结构是IOT.但是在不指定主键Primary Key的情况下,是不允许建表的. create ...

  4. heap表和iot表排序规则不同

    heap 和iot 对比 OBJECT_NAME OBJECT_TYPE --------------------------------------------------------------- ...

  5. iot表输出按主键列排序,heap表不是

    <pre name="code" class="html"> create table t1 (id char(10) primary key,a1 ...

  6. iot 表主键存放所有数据,且按数据插入顺序排序

    iot表测试: 在create table语句后面使用organization index,就指定数据表创建结构是IOT.但是在不指定主键Primary Key的情况下,是不允许建表的. create ...

  7. Mysql InnoDB 是IOT表 锁基于索引

    </pre>Mysql InnoDB 是IOT表 锁基于索引<pre>

  8. Oracle 验证IOT表数据存储在主键里

    iot表测试: 在create table语句后面使用organization index,就指定数据表创建结构是IOT.但是在不指定主键Primary Key的情况下,是不允许建表的. create ...

  9. IOT表优缺点

    <pre name="code" class="html">IOT表是将所有东西都塞到叶块中,表就是索引,可以避免回表 首先,对于IOT而言,只有索 ...

  10. Mysql iot表

    我们知道一般的表都以堆(heap)的形式来组织的,这是无序的组织方式. Oracle还提供了一种有序的表,它就是索引组织表,简称IOT表.IOT表上必须要有主键,而IOT表本身不对应segment,表 ...

随机推荐

  1. HDU 6040 Hints of sd0061(划分高低位查找)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=6040 [题目大意] 给出一个随机数生成器,有m个询问,问第bi小的元素是啥 询问中对于bi< ...

  2. css排版之-标准文档流

    标准流指的是在不使用其他的与排列和定位相关的特殊CSS规则时,各种元素的排列规则.HTML文档中的元素可以分为两大类:行内元素和块级元素.       1.行内元素不占据单独的空间,依附于块级元素,行 ...

  3. [转]MySql中创建序列的方法

    CREATE TABLE `my_seq` (    `seq` int(10) NOT NULL default 10000) ENGINE=MyISAM DEFAULT CHARSET=utf8 ...

  4. Failed to Attach to Process ID Xcode 解决办法

    方法1. go to the Product menu and find the Edit Scheme menu there. While in Edit Scheme window, select ...

  5. bootstrap table 复选框选中后,翻页不影响已选中的复选框

    使用的 jquery版本为 2.1.1 在项目中发现bootstrap table的复选框选中后,翻页操作会导致上一页选中的丢失,api中的 bootstrapTable('getSelections ...

  6. javascript 中contentWindow和 frames和iframe之间通信

    iframe父子兄弟之间通过jquery传值(contentWindow && parent),iframe的调用包括以下几个方面:(调用包含html dom,js全局变量,js方法) ...

  7. iOS:多线程同步加锁的简单介绍

    多线程同步加锁主要方式有3种:NSLock(普通锁).NSCondition(状态锁).synchronized同步代码块 还有少用的NSRecursiveLock(递归锁).NSConditionL ...

  8. piwik网站访问统计系统

    一.Piwik介绍 Piwik是一套基于PHP+MySQL技术构建的开源网站访问统计系统.Piwik可以给你详细的统计信息,比如网页浏览人数,访问最多的页面,搜索引擎关键词等流量分析功能.此外,它还采 ...

  9. asp.net 大文上传配置

    配置iis的文件上传大小控制: 今天先说一个问题,在window server2008 下配置上传文件的大小,除了工程自身的config外还需要配置一下服务器上的applicationhost.con ...

  10. linux系统下mysql跳过密码验证登录和创建新用户

    修改MySQL的登录设置: # vi /etc/my.cnf 在[mysqld]的段中加上一句:skip-grant-tables 例如: [mysqld] datadir=/var/lib/mysq ...