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 ...
随机推荐
- jquery插件Flot的简单讲解
只是说一下基本用法,举一两个例子,详细用法请查看官方文档 使用方法是要先引入jquery插件,然后引入flot插件. <script type="text/javascript&quo ...
- python 异步编程
Python 3.5 协程究竟是个啥 Yushneng · Mar 10th, 2016 原文链接 : How the heck does async/await work in Python 3.5 ...
- mysql-5.7 扩展innodb系统表空间详解
一.innodb系统表空间的简介: innodb 系统表空间是由若干个文件组成的,表空间的大小就是对应文件的大小,表空间文件是由innodb_data_file_path 这人参数来定义的.下面我们来 ...
- laravel5的Bcrypt加密方式对系统保存密码
laravel5文档介绍 //对 A 密码使用Bcrypt 加密 $password = Hash::make('mima'); //你也可直接使用 bcrypt 的 function $passwo ...
- c++中带返回值函数没写return能通过编译但运行时会出现奇怪问题
c++中带返回值函数没写return能通过编译但运行时会出现奇怪问题 例如: string myFunc(){ theLogics(); } 发现调用: myFunc(); 崩溃. 但调用: cout ...
- Java web中WEB-INF目录理解
WEB-INF是Java的WEB应用的安全目录.所谓安全就是客户端无法访问,只有服务端可以访问的目录.如果想在页面中直接访问其中的文件,必须通过web.xml文件对要访问的文件进行相应映射才能访问. ...
- WPF绑定时要绑定属性,不要绑定字段
如题(就是加get;set;),绑定属性不出东西,不知道为什么...
- 每天一点儿Java--ComboBox
import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; impor ...
- google protocol buffer的原理和使用(三)
介绍下怎么反序列化GoogleBuffer数据.并在最后提供本系列文章中所用到的代码整理供下载. 上一篇文章介绍了如何将数据序列化到了addressbook.data中.那么对于接受方而言该怎么解析出 ...
- 配置 logrotate 指导
一般来说,日志是任何故障排除过程中非常重要的一部分,但这些日志会随着时间增长.在这种情况下,我们需要手动执行日志清理以回收空间,这是一件繁琐的管理任务.为了解决这个问题,我们可以在 Linux 中配置 ...