SQL> explain plan for select *
from fxqd_list_20131115_new
where (acct_no, oper_no, seqno, trans_amt) not in
(select acct_no, oper_no, seqno, trans_amt
from fxqd_list
where reg_date = to_date('20131115', 'yyyymmdd'))
and list_type = '1'; 2 3 4 5 6 7 Explained. SQL> select * from table(dbms_xplan.display()); PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 196590019 -------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4145 | 10M| 13079 (1)| 00:02:37 |
|* 1 | FILTER | | | | | |
|* 2 | TABLE ACCESS FULL | FXQD_LIST_20131115_NEW | 4145 | 10M| 180 (2)| 00:00:03 |
|* 3 | TABLE ACCESS BY INDEX ROWID| FXQD_LIST | 2036 | 157K| 4 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | FXQD_LIST_IDX_1 | 2500 | | 3 (0)| 00:00:01 |
------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id):
--------------------------------------------------- 1 - filter( NOT EXISTS (SELECT /*+ */ 0 FROM "FXQD_LIST" "FXQD_LIST" WHERE
"REG_DATE"=TO_DATE(' 2013-11-15 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND LNNVL("ACCT_NO"<>:B1)
AND LNNVL("OPER_NO"<>:B2) AND LNNVL("SEQNO"<>:B3) AND LNNVL("TRANS_AMT"<>:B4)))
2 - filter("LIST_TYPE"='1')
3 - filter(LNNVL("ACCT_NO"<>:B1) AND LNNVL("OPER_NO"<>:B2) AND LNNVL("SEQNO"<>:B3) AND
LNNVL("TRANS_AMT"<>:B4))
4 - access("REG_DATE"=TO_DATE(' 2013-11-15 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) Note
-----
- dynamic sampling used for this statement 26 rows selected. 查看特殊执行计划:
SQL> select * from table(dbms_xplan.display_cursor(null,null,'allstats last')); PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID fg7h5y1451z61, child number 0
-------------------------------------
select * from fxqd_list_20131115_new where (acct_no, oper_no, seqno, trans_amt) not in (select acct_no,
oper_no, seqno, trans_amt from fxqd_list where reg_date = to_date('20131115', 'yyyymmdd'))
and list_type = '1' Plan hash value: 196590019 --------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Starts | E-Rows | A-Rows | A-Time | Buffers | Reads |
--------------------------------------------------------------------------------------------------------------------------
|* 1 | FILTER | | 1 | | 103 |00:00:32.10 | 1563K| 225 |
|* 2 | TABLE ACCESS FULL | FXQD_LIST_20131115_NEW | 1 | 4145 | 4159 |00:00:00.13 | 795 | 225 |
|* 3 | TABLE ACCESS BY INDEX ROWID| FXQD_LIST | 4159 | 2036 | 4056 |00:00:31.95 | 1562K| 0 |
|* 4 | INDEX RANGE SCAN | FXQD_LIST_IDX_1 | 4159 | 2500 | 14M|00:00:03.55 | 67954 | 0 |
-------------------------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id):
--------------------------------------------------- 1 - filter( IS NULL)
2 - filter("LIST_TYPE"='1')
3 - filter((LNNVL("ACCT_NO"<>:B1) AND LNNVL("OPER_NO"<>:B2) AND LNNVL("SEQNO"<>:B3) AND
LNNVL("TRANS_AMT"<>:B4)))
4 - access("REG_DATE"=TO_DATE(' 2013-11-15 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) Note
-----
- dynamic sampling used for this statement 30 rows selected. 利用with as 改写:
SQL> with D as (select /*+ materialize*/ acct_no, oper_no, seqno, trans_amt
from fxqd_list
where reg_date = to_date('20131115', 'yyyymmdd'))
select * from fxqd_list_20131115_new where (acct_no, oper_no, seqno, trans_amt) not in
(select acct_no, oper_no, seqno, trans_amt from D)
and list_type = '1'; 2 3 4 5 6 103 rows selected. Execution Plan
----------------------------------------------------------
Plan hash value: 2773456887 -------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4145 | 10M| 26570 (1)| 00:05:19 |
| 1 | TEMP TABLE TRANSFORMATION | | | | | |
| 2 | LOAD AS SELECT | FXQD_LIST_20131115_NEW | | | | |
| 3 | TABLE ACCESS BY INDEX ROWID| FXQD_LIST | 2500 | 192K| 389 (1)| 00:00:05 |
|* 4 | INDEX RANGE SCAN | FXQD_LIST_IDX_1 | 2500 | | 10 (0)| 00:00:01 |
|* 5 | FILTER | | | | | |
|* 6 | TABLE ACCESS FULL | FXQD_LIST_20131115_NEW | 4145 | 10M| 180 (2)| 00:00:03 |
|* 7 | VIEW | | 2500 | 170K| 8 (0)| 00:00:01 |
| 8 | TABLE ACCESS FULL | SYS_TEMP_0FD9D66DA_A4F53A1D | 2500 | 170K| 8 (0)| 00:00:01 |
------------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id):
--------------------------------------------------- 4 - access("REG_DATE"=TO_DATE(' 2013-11-15 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
5 - filter( NOT EXISTS (SELECT /*+ */ 0 FROM (SELECT /*+ CACHE_TEMP_TABLE ("T1") */ "C0"
"ACCT_NO","C1" "OPER_NO","C2" "SEQNO","C3" "TRANS_AMT" FROM "SYS"."SYS_TEMP_0FD9D66DA_A4F53A1D"
"T1") "D" WHERE LNNVL("ACCT_NO"<>:B1) AND LNNVL("OPER_NO"<>:B2) AND LNNVL("SEQNO"<>:B3) AND
LNNVL("TRANS_AMT"<>:B4)))
6 - filter("LIST_TYPE"='1')
7 - filter(LNNVL("ACCT_NO"<>:B1) AND LNNVL("OPER_NO"<>:B2) AND LNNVL("SEQNO"<>:B3) AND
LNNVL("TRANS_AMT"<>:B4)) Note
-----
- dynamic sampling used for this statement Statistics
----------------------------------------------------------
171 recursive calls
64 db block gets
123638 consistent gets
55 physical reads
1556 redo size
43694 bytes sent via SQL*Net to client
558 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
103 rows processed 如果不加/*+ materialize*/ hints呢?
SQL> with D as (select acct_no, oper_no, seqno, trans_amt
from fxqd_list
where reg_date = to_date('20131115', 'yyyymmdd'))
select * from fxqd_list_20131115_new where (acct_no, oper_no, seqno, trans_amt) not in
(select acct_no, oper_no, seqno, trans_amt from D)
and list_type = '1'; 2 3 4 5 6 103 rows selected. Execution Plan
----------------------------------------------------------
Plan hash value: 196590019 -------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 4145 | 10M| 13079 (1)| 00:02:37 |
|* 1 | FILTER | | | | | |
|* 2 | TABLE ACCESS FULL | FXQD_LIST_20131115_NEW | 4145 | 10M| 180 (2)| 00:00:03 |
|* 3 | TABLE ACCESS BY INDEX ROWID| FXQD_LIST | 2036 | 157K| 4 (0)| 00:00:01 |
|* 4 | INDEX RANGE SCAN | FXQD_LIST_IDX_1 | 2500 | | 3 (0)| 00:00:01 |
------------------------------------------------------------------------------------------------------- Predicate Information (identified by operation id):
--------------------------------------------------- 1 - filter( NOT EXISTS (SELECT /*+ */ 0 FROM "FXQD_LIST" "FXQD_LIST" WHERE
"REG_DATE"=TO_DATE(' 2013-11-15 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND LNNVL("ACCT_NO"<>:B1)
AND LNNVL("OPER_NO"<>:B2) AND LNNVL("SEQNO"<>:B3) AND LNNVL("TRANS_AMT"<>:B4)))
2 - filter("LIST_TYPE"='1')
3 - filter(LNNVL("ACCT_NO"<>:B1) AND LNNVL("OPER_NO"<>:B2) AND LNNVL("SEQNO"<>:B3) AND
LNNVL("TRANS_AMT"<>:B4))
4 - access("REG_DATE"=TO_DATE(' 2013-11-15 00:00:00', 'syyyy-mm-dd hh24:mi:ss')) Note
-----
- dynamic sampling used for this statement Statistics
----------------------------------------------------------
19 recursive calls
0 db block gets
1564063 consistent gets
0 physical reads
0 redo size
43694 bytes sent via SQL*Net to client
558 bytes received via SQL*Net from client
8 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
103 rows processed

利用WITH AS 优化FILTER的更多相关文章

  1. 利用函数索引优化<>

    SQL> select count(*),ID from test_2 group by id; COUNT(*) ID ---------- ---------- 131072 1 11796 ...

  2. 【阿里云产品公测】利用PTS服务优化网站数据库读写性能

    [阿里云产品公测]利用PTS服务优化网站数据库读写性能 作者:阿里云用户千鸟 写这个帖子主要也是因为在用PTS测试网站的时候,手动访问网站进入报错页面,主要原因是数据库连接对象存在问题,导致并发多的时 ...

  3. 看了一本书,说可以利用Hierarchy Viewer优化布局

    看了一本书,说可以利用Hierarchy Viewer优化布局,今以志之. 参考:http://www.cnblogs.com/Rocky_/archive/2011/11/04/2236243.ht ...

  4. 产品设计教程:利用“系列位置效应”优化UI

    任何博得人们喜欢的产品都在一定程度上契合了用户的心理需求.设计和心理学息息相关,掌握一些基本心理学知识,设计师的作品更能在潜意识中抓住用户的心. 系列位置效应 “系列位置效应”(The Serial ...

  5. Web Api 内部数据思考 和 利用http缓存优化 Api

    在上篇<Web Api 端点设计 与 Oauth>后,接着我们思考Web Api 的内部数据: 其他文章:<API接口安全加强设计方法> 第一  实际使用应该返回怎样的数据 ? ...

  6. 利用Cayley-Hamilton theorem 优化矩阵线性递推

    平时有关线性递推的题,很多都可以利用矩阵乘法来解决. 时间复杂度一般是O(K3logn)因此对矩阵的规模限制比较大. 下面介绍一种利用利用Cayley-Hamilton theorem加速矩阵乘法的方 ...

  7. SQL Server 利用锁提示优化Row_number()-程序员需知

    网站中一些老页面仍采用Row_number类似的开窗函数进行分页处理,此时如果遭遇挖坟帖的情形可能就需要漫长的等待且消耗巨大.这里给大家介绍根据Row_number()特性采用特定锁Hint提升查询速 ...

  8. Android(java)学习笔记206:利用开源SmartImageView优化网易新闻RSS客户端

    1.我们自己编写的SmartImageView会有很多漏洞,但是我们幸运的可以在网上利用开源项目的,开源项目中有很多成熟的代码,比如SmartImageView都编写的很成熟的 国内我们经常用到htt ...

  9. Android(java)学习笔记149:利用开源SmartImageView优化网易新闻RSS客户端

    1.我们自己编写的SmartImageView会有很多漏洞,但是我们幸运的可以在网上利用开源项目的,开源项目中有很多成熟的代码,比如SmartImageView都编写的很成熟的 国内我们经常用到htt ...

随机推荐

  1. 安装指南:Win10下安装CentOs7

    系统安装 安装准备 系统:CentOS 7.Win 10 硬件:U盘一枚.PC一台 软件:UltraISO 安装步骤 使用UltraISO将镜像写入U盘 window10使用磁盘管理,空出一个未分配的 ...

  2. Windows Python 2.7 安装 Numpy

    为了防止无良网站的爬虫抓取文章,特此标识,转载请注明文章出处.LaplaceDemon/ShiJiaqi. http://www.cnblogs.com/shijiaqi1066/p/4846093. ...

  3. CS=0xFFFF IP=0x0000与CS=F000 IP=FFF0

    计算机自动上电后,有些书上说CS=0xFFFF IP=0x0000,例如linux内核设计的艺术(第三版).也有一些书说CS=F000 IP=FFF0,例如赵炯的linux内核完全注释. 其实并不是说 ...

  4. Python实战:美女图片下载器,海量图片任你下载

    Python应用现在如火如荼,应用范围很广.因其效率高开发迅速的优势,快速进入编程语言排行榜前几名.本系列文章致力于可以全面系统的介绍Python语言开发知识和相关知识总结.希望大家能够快速入门并学习 ...

  5. (转)Spring读书笔记-----使用Spring容器(二)

    一.使用ApplicationContext 前面介绍了,我们一般不会使用BeanFactory实例作为Spring容器,而是使用ApplicationContext实例作为容器,它增强了BeanFa ...

  6. declare-styleable:自定义控件的属性

    http://www.cnblogs.com/jisheng/archive/2013/01/10/2854891.html 在使用过程中, 1 TypedArray a = getContext() ...

  7. Access restriction:The type JPEGCodec is not accessible due to restriction on required library C:\Program Files\Java\jre6\lib\rt.jar

    解决方法: Project -> Properties -> libraries, 先remove掉JRE System Library,然后再Add Library重新加入. ===== ...

  8. Linq XML

    写得比较啰嗦,自己记载备用   1 public class XmlFunction   2     {   3         private static XDocument _doc = new ...

  9. redis【摘自网上,只为以后查看】

    ubuntu安装启动redis 1.下载安装 cd /tmp wget http://redis.googlecode.com/files/redis-2.2.13.tar.gz tar -zxf r ...

  10. ES6学习笔记之Promise

    入职百度EFE团队实习已经三周了,实习中接触到了生产环境的技术和开发流程,大开眼界,和自己在学校接小作坊式项目是很不一样的体验.其中一个很大的感触是,ES6早已不是“选修”的尝鲜技术,而是已经全面普及 ...