【12c新特性】12cR1 ROWID IO Batching特性

简介:
在介绍12cR1的这个优化器特性之前,我们先来看如下的例子:  
SQL> create table sample nologging tablespace users as select rownum t1  from dual  connect by level<=900000;

Table created.

SQL> alter table sample add t2 number;

Table altered.

update sample set t2=dbms_random.value(1,999999);

900000 rows updated.

SQL> commit;
Commit complete.

SQL> create index ind_t1 on sample(t1) nologging tablespace users;
Index created.

SQL> create index ind_t2 on sample(t2) nologging tablespace users;
Index created.

SQL> exec dbms_stats.gather_table_stats(USER,'SAMPLE',cascade=>TRUE);
PL/SQL procedure successfully completed.

SQL> select blocks,NUM_ROWS from dba_tables where table_name='SAMPLE';

    BLOCKS   NUM_ROWS
---------- ----------
      9107     902319

SQL> select CLUSTERING_FACTOR,LEAF_BLOCKS,DISTINCT_KEYS,index_name from dba_indexes where table_name='SAMPLE';

CLUSTERING_FACTOR LEAF_BLOCKS DISTINCT_KEYS INDEX_NAME
----------------- ----------- ------------- ------------------------------
             1370        2004        900000 IND_T1
           899317        4148        900000 IND_T2

alter session set events '10046 trace name context forever,level 12';

set autotrace traceonly;

alter system flush buffer_cache;

alter session set "_optimizer_batch_table_access_by_rowid"=true;

 select /*+ index(sample ind_t2) */ * from sample where t2 between 1 and 999997;

 select /*+ index(sample ind_t2) */ *
from
 sample where t2 between 1 and 999997

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch    60001      4.68       8.56      12754    1810330          0      899999
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total    60003      4.68       8.56      12754    1810330          0      899999

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
    899999     899999     899999  TABLE ACCESS BY INDEX ROWID BATCHED SAMPLE (cr=1810330 pr=12754 pw=0 time=20413784 us cost=903657 size=24300000 card=900000)
    899999     899999     899999   INDEX RANGE SCAN IND_T2 (cr=63873 pr=4150 pw=0 time=4655140 us cost=4155 size=0 card=900000)(object id 92322)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                   60001        0.00          0.32
  Disk file operations I/O                        1        0.00          0.00
  db file sequential read                     11388        0.00          1.70
  SQL*Net message from client                 60001        0.00          8.95
  db file parallel read                         197        0.00          0.00

 alter system flush buffer_cache;

alter session set "_optimizer_batch_table_access_by_rowid"=false;

 select /*+ index(sample ind_t2) */ * from sample where t2 between 1 and 999997;

 select /*+ index(sample ind_t2) */ *
from
 sample where t2 between 1 and 999997

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch    60001      4.70       8.82      12754    1810333          0      899999
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total    60003      4.70       8.82      12754    1810333          0      899999

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: SYS
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
    899999     899999     899999  TABLE ACCESS BY INDEX ROWID SAMPLE (cr=1810333 pr=12754 pw=0 time=25464232 us cost=903657 size=24300000 card=900000)
    899999     899999     899999   INDEX RANGE SCAN IND_T2 (cr=63874 pr=4150 pw=0 time=4404956 us cost=4155 size=0 card=900000)(object id 92322)

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                   60001        0.00          0.32
  db file sequential read                     12754        0.00          1.85
  SQL*Net message from client                 60001        0.00          8.95

    我们看到了一个陌生的operation "



本文转自maclean_007 51CTO博客,原文链接:http://blog.51cto.com/maclean/p2

相关文章
|
2月前
|
存储 传感器 数据可视化
【软件设计师备考 专题 】IO接口的功能、类型和特性
【软件设计师备考 专题 】IO接口的功能、类型和特性
52 1
|
10月前
|
缓存 监控 关系型数据库
[译]PostgreSQL16-新特性-新增IO统计视图:pg_stat_io
[译]PostgreSQL16-新特性-新增IO统计视图:pg_stat_io
166 0
|
Java 开发工具 Windows
和低效 IO 说再见,回头补一波 Java 7 的 NIO.2 特性
和低效 IO 说再见,回头补一波 Java 7 的 NIO.2 特性
144 0
和低效 IO 说再见,回头补一波 Java 7 的 NIO.2 特性
|
NoSQL Redis
Redis的IO多路复用和多线程特性会破坏分布式锁的原子性吗?(下)
Redis的IO多路复用和多线程特性会破坏分布式锁的原子性吗?
227 0
Redis的IO多路复用和多线程特性会破坏分布式锁的原子性吗?(下)
|
NoSQL Redis
Redis的IO多路复用和多线程特性会破坏分布式锁的原子性吗?(中)
Redis的IO多路复用和多线程特性会破坏分布式锁的原子性吗?
111 0
Redis的IO多路复用和多线程特性会破坏分布式锁的原子性吗?(中)
|
移动开发 NoSQL 算法
Redis的IO多路复用和多线程特性会破坏分布式锁的原子性吗?(上)
Redis的IO多路复用和多线程特性会破坏分布式锁的原子性吗?
168 0
Redis的IO多路复用和多线程特性会破坏分布式锁的原子性吗?(上)
|
关系型数据库 MySQL
MySQL · 引擎特性 · IO_CACHE 源码解析
概述 在数据库中 IO 的重要性不言而喻,为了更好的管理 IO 操作,大多数数据库都自己管理页数据和刷脏机制(例如 InnoDB 中的 Buffer pool),而不是交给文件系统甚至是操作系统调度。但是对于顺序写入的日志数据,使用文件系统接口方便的多,文件系统 也是以页的形式管理,呈现给应用层的是一片连续可写的空间,管理的单位称为 Sector 大小是 4KB,所以对于 4KB 对齐的地址读写可以避免跨多个 Sector,对文件系统的性能有很大的提高。
1861 0
|
存储 关系型数据库 数据库
|
1月前
|
存储 缓存 安全
Java 中 IO 流、File文件
Java 中 IO 流、File文件
|
15天前
|
Java Unix Windows