WITH AS 优化逻辑读

时间:2023-03-08 22:35:24
SQL> 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 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
----------------------------------------------------------
3505 recursive calls
2 db block gets
1564672 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
16 sorts (memory)
0 sorts (disk)
103 rows processed 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: 1295716977 -------------------------------------------------------------------------------------------------------------
| 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_0FD9D66DD_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_0FD9D66DD_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
----------------------------------------------------------
2365 recursive calls
64 db block gets
124525 consistent gets
55 physical reads
1516 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
46 sorts (memory)
0 sorts (disk)
103 rows processed