ITPub博客

首页 > Linux操作系统 > Linux操作系统 > materialize hint, inline hint

materialize hint, inline hint

原创 Linux操作系统 作者:xjc0512 时间:2013-01-03 22:33:14 0 删除 编辑
看cost-based oracle fundamentals一书的时候,看到使用 materialize 提示。之前从来没用过这个提示,于是google一把。
使用范围: 用于with clause。
作用: 针对with中的查询,先建立一个 global temporary table, 之后查询这个临时表。执行某些sql的时候,特别是多次使用with子查询的时候,会提升速度。
与之相对还有一个inline hint,  Oracle指示所有的部分查询不使用TEMP TABLE TRANSFORMATION。

SQL> CREATE TABLE t0103_1 NOLOGGING AS SELECT * FROM dba_objects where ROWNUM<10000;

Table created.

SQL> with tmp as (select * from t0103) select * from tmp;

Execution Plan
----------------------------------------------------------
Plan hash value: 2929628763

---------------------------------------------------------------------------
| Id  | Operation         | Name  | Rows  | Bytes | Cost (%CPU)| Time     |
---------------------------------------------------------------------------
|   0 | SELECT STATEMENT  |       |   999 | 87912 |   174   (0)| 00:00:03 |
|   1 |  TABLE ACCESS FULL| T0103 |   999 | 87912 |   174   (0)| 00:00:03 |
---------------------------------------------------------------------------

SQL> with tmp as (select /*+ materialize */ * from t0103) select * from tmp;

Execution Plan
----------------------------------------------------------
Plan hash value: 877440232

--------------------------------------------------------------------------------------------------------
| Id  | Operation                  | Name                      | Rows  | Bytes | Cost (%CPU)| Time     |
--------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT           |                           |   999 |   201K|   178   (0)| 00:00:03 |
|   1 |  TEMP TABLE TRANSFORMATION |                           |       |       |            |          |
|   2 |   LOAD AS SELECT           | SYS_TEMP_0FD9D660B_1690D1 |       |       |            |          |
|   3 |    TABLE ACCESS FULL       | T0103                     |   999 | 87912 |   174   (0)| 00:00:03 |
|   4 |   VIEW                     |                           |   999 |   201K|     4   (0)| 00:00:01 |
|   5 |    TABLE ACCESS FULL       | SYS_TEMP_0FD9D660B_1690D1 |   999 | 87912 |     4   (0)| 00:00:01 |
--------------------------------------------------------------------------------------------------------

参考: http://dioncho.wordpress.com/tag/inline/
             http://caohong286.iteye.com/blog/1528711

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/23700752/viewspace-752037/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: copy to支持parallel
下一篇: 没有了~
请登录后发表评论 登录
全部评论

注册时间:2010-04-11

  • 博文量
    10
  • 访问量
    35055