oracle hint inline materialize
当我们使用with的时候,oracle可能会把with里面的结果转换为暂时表。这是仅仅是可能,由于CBO会推断。
inline是不转换成暂时表。materialize是强制转换成暂时表。
制造数据
drop table test1 purge;
drop table test2 purge;
drop table test3 purge;
create table test1 as select * from dba_objects;
create table test2 as select * from user_objects;
create table test3 as select * from dba_objects;
exec dbms_stats.gather_table_stats(user,'test1');
exec dbms_stats.gather_table_stats(user,'test2');
exec dbms_stats.gather_table_stats(user,'test3');
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> set autotrace traceonly
SQL> with t as(select t1.* from test1 t1,test2 t2
where t1.object_id=t2.object_id)
select * from t,test3 t3 where t.object_id=t3.object_id;
已选择1931行。
已用时间: 00: 00: 00.20
运行计划
----------------------------------------------------------
Plan hash value: 1215971386
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1931 | 382K| 409 (2)| 00:00:06 |
|* 1 | HASH JOIN | | 1931 | 382K| 409 (2)| 00:00:06 |
|* 2 | HASH JOIN | | 1932 | 196K| 210 (2)| 00:00:03 |
| 3 | TABLE ACCESS FULL| TEST2 | 1934 | 9670 | 10 (0)| 00:00:01 |
| 4 | TABLE ACCESS FULL| TEST1 | 71347 | 6897K| 199 (2)| 00:00:03 |
| 5 | TABLE ACCESS FULL | TEST3 | 71349 | 6897K| 199 (2)| 00:00:03 |
-----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."OBJECT_ID"="T3"."OBJECT_ID")
2 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
1173 consistent gets
0 physical reads
0 redo size
139087 bytes sent via SQL*Net to client
1768 bytes received via SQL*Net from client
130 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1931 rows processed
使用hint inline
SQL> with t as(select /*+inline*/t1.* from test1 t1,test2 t2
where t1.object_id=t2.object_id)
select * from t,test3 t3 where t.object_id=t3.object_id;
已选择1931行。
已用时间: 00: 00: 00.21
运行计划
----------------------------------------------------------
Plan hash value: 1215971386
-----------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-----------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1931 | 382K| 409 (2)| 00:00:06 |
|* 1 | HASH JOIN | | 1931 | 382K| 409 (2)| 00:00:06 |
|* 2 | HASH JOIN | | 1932 | 196K| 210 (2)| 00:00:03 |
| 3 | TABLE ACCESS FULL| TEST2 | 1934 | 9670 | 10 (0)| 00:00:01 |
| 4 | TABLE ACCESS FULL| TEST1 | 71347 | 6897K| 199 (2)| 00:00:03 |
| 5 | TABLE ACCESS FULL | TEST3 | 71349 | 6897K| 199 (2)| 00:00:03 |
-----------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T1"."OBJECT_ID"="T3"."OBJECT_ID")
2 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
统计信息
----------------------------------------------------------
1 recursive calls
0 db block gets
1173 consistent gets
0 physical reads
0 redo size
139087 bytes sent via SQL*Net to client
1768 bytes received via SQL*Net from client
130 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1931 rows processed
使用hint materialize
SQL> with t as(select /*+materialize*/t1.* from test1 t1,test2 t2
where t1.object_id=t2.object_id)
select * from t,test3 t3 where t.object_id=t3.object_id;
已选择1931行。
已用时间: 00: 00: 00.21
运行计划
----------------------------------------------------------
Plan hash value: 1492452360
----------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1925 | 575K| 416 (2)| 00:00:06 |
| 1 | TEMP TABLE TRANSFORMATION | | | | | |
| 2 | LOAD AS SELECT | SYS_TEMP_0FD9D660C_9A3A2AEA | | | | |
|* 3 | HASH JOIN | | 1932 | 196K| 210 (2)| 00:00:03 |
| 4 | TABLE ACCESS FULL | TEST2 | 1934 | 9670 | 10 (0)| 00:00:01 |
| 5 | TABLE ACCESS FULL | TEST1 | 71347 | 6897K| 199 (2)| 00:00:03 |
|* 6 | HASH JOIN | | 1925 | 575K| 207 (2)| 00:00:03 |
| 7 | VIEW | | 1932 | 390K| 7 (0)| 00:00:01 |
| 8 | TABLE ACCESS FULL | SYS_TEMP_0FD9D660C_9A3A2AEA | 1932 | 196K| 7 (0)| 00:00:01 |
| 9 | TABLE ACCESS FULL | TEST3 | 71349 | 6897K| 199 (2)| 00:00:03 |
----------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("T1"."OBJECT_ID"="T2"."OBJECT_ID")
6 - access("T"."OBJECT_ID"="T3"."OBJECT_ID")
统计信息
----------------------------------------------------------
394 recursive calls
25 db block gets
1243 consistent gets
18 physical reads
600 redo size
139087 bytes sent via SQL*Net to client
1768 bytes received via SQL*Net from client
130 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1931 rows processed
oracle hint inline materialize的更多相关文章
- SWAP_JOIN_INPUTS Oracle Hint(处理hash join强制大表(segment_size大)作为被驱动表)
SWAP_JOIN_INPUTS Oracle Hint(处理hash join强制大表(segment_size大)作为被驱动表) swap_join_inputs是针对哈希连接的hint,它的含义 ...
- SQL优化过程中常见Oracle HINT
在SQL语句优化过程中,我们经常会用到hint,现总结一下在SQL优化过程中常见Oracle HINT的用法: 1. /*+ALL_ROWS*/ 表明对语句块选择基于开销的优化方法,并获得最佳吞吐量, ...
- Oracle hint手动优化
例子 select/*+FULL(fortest)*/ * from fortest where id = 2000000 //使用0.70s时间 select* from fortest where ...
- 品味性能之道<十>:Oracle Hint
Hint 是Oracle 提供的一种SQL语法,它允许用户在SQL语句中插入相关的语法,从而影响SQL的执行方式. 因为Hint的特殊作用,所以对于开发人员不应该在代码中使用它,Hint 更像是Ora ...
- Oracle Hint 用法
正确的语法是: select /*+ index(x idx_t) */ * from t x where x.object_id=123 /*+ */ 和注释很像,比注释多了一个“+”,这就是 ...
- Oracle Hint 详解
Hint 是Oracle 提供的一种SQL语法,它允许用户在SQL语句中插入相关的语法,从而影响SQL的执行方式. 因为Hint的特殊作用,所以对于开发人员不应该在代码中使用它,Hint 更像是Ora ...
- Oracle hint之ORDERED和USE_NL
Hint:ORDERED和USE_NL ORDERED好理解,就是表示根据 from 后面表的顺序join,从左到右,左边的表做驱动表 use_nl(t1,t2):表示对表t1.t2关联时采用嵌套循环 ...
- oracle --hint总结
得到一条sql语句执行计划的常用方法:1.explain plan 命令 2.DBMS_XPLAN包3.sqlplus中的AUTOTRACE开关4.10046事件5.10053事件6.AWR报告或者 ...
- Oracle Hint用法整理笔记
目录 1./+ result_cache / 2./+ connect_by_filtering / 3./+ no_unnset / 4./+ index(表别名 索引名) / 5./+ INDEX ...
随机推荐
- win10环境配置react
1 react 需要nodejs所以需要安装nodejs环境,到nodejs官网下载 现在默认会安装nodejs 和 npm包 和 配置环境 2 检查是否安装成功,在命令行中输入 显示成功则正确 3 ...
- ps抠图
*套索工具:简单抠图 *多边形套索工具:简单抠图 *磁性套索工具:可以自动贴着走 *快速选择工具抠图,使用方法:主要控制画笔大小. *魔术棒抠图,使用方法:主要控制容差大小 *钢笔抠图,常见商业抠图 ...
- libgdx 1.4.1公布
(转载自http://www.libgdx.cn/topic/4/libgdx-1-4-1%E5%8F%91%E5%B8%83) libgdx从未停止进步的脚步.10月10日.libgdx1.4.1公 ...
- ORACLE 新增记录 & 更新记录
开发中偶尔需要新增一条记录或修改一条记录的几个字段,语法中有微妙的区别. 由于不是经常写,久不写就忘记了,而又要重新查找或调试. 新增记录语法: --新增记录(仿照已有表记录)INSERT INTO ...
- USB设备驱动程序学习笔记(一)
现象:把USB设备接到PC1. 右下角弹出"发现android phone"2. 跳出一个对话框,提示你安装驱动程序 问1. 既然还没有"驱动程序",为何能知道 ...
- Tomcat的URL中文乱码解决以及传输优化
默认的tomcat容器如果直接使用get方式在url中传中文时,传到后台接收会是乱码. 乱码问题 原因: tomcat默认的在url传输时是用iso8859-1编码. 解决方案一: 在使用get传输参 ...
- LeetCode: Median of Two Sorted Arrays 解题报告
Median of Two Sorted Arrays There are two sorted arrays A and B of size m and n respectively. Find t ...
- RTX——第10章 任务调度-抢占式、时间片和合作式
以下内容转载自安富莱电子: http://forum.armfly.com/forum.php 本章教程为大家将介绍 RTX 操作系统支持的任务调度方式,抢占式,时间片和合作式,这部分算是RTX 操作 ...
- 面试-默认参数(传值)、var(传址)、out(输出)、const(常数)
相关资料:1.http://blog.csdn.net/rznice/article/details/69600112.http://www.cnblogs.com/echomyecho/archiv ...
- Elasticsearch的javaAPI之get,delete,bulk
Elsasticsearch的javaAPI之get get API同意依据其id获得指定index中的基于json document.以下的样例得到一个JSON document(index为twi ...