• FILTER再来一例


    explain plan for SELECT    a.trans_org as 机构代码
    
    FROM   (select x.trans_org,
                   x.ext_acct_no,
                   x.acct_seqno,
                   y.agmt_id,
                   
                   x.cust_no
            from   (select *
                    from   dwf.f_evt_savr_bigtrans
                    where  trans_date >= To_Date('2013-12-03', 'YYYY-MM-DD')
                           AND trans_date <= TO_DATE('2014-03-05', 'YYYY-MM-DD')
                           AND trans_org in
                           (SELECT t.Org_Id
                                FROM   b_m_Sys_Branch t
                                WHERE  t.Status = 1
                                       AND t.Dept_Flag != '2'
                                CONNECT BY PRIOR t.Id = t.Parent_Id
                                START  WITH t.Org_Id = 10000)) x,
                   (select ab.*, e.bus_name
                    from   (select *
                            From   dwf.f_agt_savb_acctinfo_h
                            where  start_dt <= TO_DATE('2014-01-05', 'YYYY-MM-DD')
                                   AND
                                   end_dt > TO_DATE('2014-01-05', 'YYYY-MM-DD')) ab
                    left   join dwf.f_savc_buscode e
                    ON     ab.bus_code = e.bus_code
                           AND ab.term = e.term
                           AND ab.subj_cd = e.subj_cd) y
            where  x.ext_acct_no = y.agmt_id
                   and x.acct_seqno = y.acct_seqno) a
    
    LEFT   JOIN (select distinct pty_id,
                                 (case
                                   when pty_type = 'T28010' then
                                    pty_type
                                   else
                                    'T28020'
                                 end) pty_type
                 from   dwf.f_pty_table
                 where  end_dt = to_date('2999-12-31', 'YYYY-MM-DD')) g
    ON     a.cust_no = g.pty_id;
    
    
    select * from table(dbms_xplan.display());
    
    Plan hash value: 4248383368
     
    ---------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                                        | Name                       | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                                 |                            |  4704 |   771K|       | 86671   (1)| 00:17:21 |
    |*  1 |  HASH JOIN OUTER                                 |                            |  4704 |   771K|       | 86671   (1)| 00:17:21 |
    |*  2 |   HASH JOIN RIGHT OUTER                          |                            |  4048 |   592K|       | 75266   (1)| 00:15:04 |
    |*  3 |    TABLE ACCESS FULL                             | F_SAVC_BUSCODE             |   400 |  5600 |       |     5   (0)| 00:00:01 |
    |   4 |    NESTED LOOPS                                  |                            |  4048 |   537K|       | 75260   (1)| 00:15:04 |
    |   5 |     NESTED LOOPS                                 |                            |  4048 |   537K|       | 75260   (1)| 00:15:04 |
    |*  6 |      HASH JOIN                                   |                            |  4048 |   328K|       | 59961   (1)| 00:12:00 |
    |   7 |       VIEW                                       | VW_NSO_1                   |     1 |    27 |       |     4  (25)| 00:00:01 |
    |   8 |        HASH UNIQUE                               |                            |     1 |    49 |       |     4  (25)| 00:00:01 |
    |*  9 |         FILTER                                   |                            |       |       |       |            |          |
    |* 10 |          CONNECT BY NO FILTERING WITH SW (UNIQUE)|                            |       |       |       |            |          |
    |  11 |           TABLE ACCESS FULL                      | B_M_SYS_BRANCH             |    82 |  1640 |       |     3   (0)| 00:00:01 |
    |* 12 |       TABLE ACCESS FULL                          | F_EVT_SAVR_BIGTRANS        |   421K|    22M|       | 59956   (1)| 00:12:00 |
    |* 13 |      INDEX RANGE SCAN                            | F_AGT_SAVB_ACCTINFO_H_IDX2 |     1 |       |       |     3   (0)| 00:00:01 |
    |* 14 |     TABLE ACCESS BY INDEX ROWID                  | F_AGT_SAVB_ACCTINFO_H      |     1 |    53 |       |     4   (0)| 00:00:01 |
    |  15 |   VIEW                                           |                            |   590K|    10M|       | 11403   (1)| 00:02:17 |
    |  16 |    HASH UNIQUE                                   |                            |   590K|    19M|    24M| 11403   (1)| 00:02:17 |
    |* 17 |     TABLE ACCESS FULL                            | F_PTY_TABLE                |   590K|    19M|       |  6032   (1)| 00:01:13 |
    ---------------------------------------------------------------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       1 - access("F_EVT_SAVR_BIGTRANS"."CUST_NO"="G"."PTY_ID"(+))
       2 - access("F_AGT_SAVB_ACCTINFO_H"."SUBJ_CD"="E"."SUBJ_CD"(+) AND "E"."TERM"(+)=TO_NUMBER("F_AGT_SAVB_ACCTINFO_H"."TERM") 
                  AND "E"."BUS_CODE"(+)=TO_NUMBER("F_AGT_SAVB_ACCTINFO_H"."BUS_CODE"))
       3 - filter("E"."SUBJ_CD"(+) IS NOT NULL)
       6 - access("TRANS_ORG"="ORG_ID")
       9 - filter("T"."STATUS"=1 AND "T"."DEPT_FLAG"<>'2')
      10 - access("T"."PARENT_ID"=PRIOR "T"."ID")
           filter(TO_NUMBER("T"."ORG_ID")=10000)
      12 - filter("TRANS_DATE">=TO_DATE(' 2013-12-03 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "TRANS_DATE"<=TO_DATE(' 2014-03-05 
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      13 - access("F_EVT_SAVR_BIGTRANS"."EXT_ACCT_NO"="F_AGT_SAVB_ACCTINFO_H"."AGMT_ID" AND 
                  "F_EVT_SAVR_BIGTRANS"."ACCT_SEQNO"="F_AGT_SAVB_ACCTINFO_H"."ACCT_SEQNO")
      14 - filter("END_DT">TO_DATE(' 2014-01-05 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "START_DT"<=TO_DATE(' 2014-01-05 
                  00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
      17 - filter("END_DT"=TO_DATE(' 2999-12-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
    
    SELECT    a.trans_org as 禄煤?
    FROM   (select  x.trans_org,
                   x.ext_acct_no,
                   x.acct_seqno,
                   y.agmt_id,
                   x.cust_no
            from   (select   *
                    from   dwf.f_evt_savr_bigtrans
                    where  trans_date >= To_Date('2013-12-03', 'YYYY-MM-DD')
                           AND trans_date <= TO_DATE('2014-03-05', 'YYYY-MM-DD')
                           AND trans_org in
                           (SELECT /*+ no_unnest*/  t.Org_Id
                                FROM   b_m_Sys_Branch t
                                WHERE  t.Status = 1
                                       AND t.Dept_Flag != '2'
                                CONNECT BY PRIOR t.Id = t.Parent_Id
                                START  WITH t.Org_Id = 10000)) x,
                   (select ab.*, e.bus_name
                    from   (select *
                            From   dwf.f_agt_savb_acctinfo_h
                            where  start_dt <= TO_DATE('2014-01-05', 'YYYY-MM-DD')
                                   AND
                                   end_dt > TO_DATE('2014-01-05', 'YYYY-MM-DD')) ab
                    left   join dwf.f_savc_buscode e
                    ON     ab.bus_code = e.bus_code
                           AND ab.term = e.term
                           AND ab.subj_cd = e.subj_cd) y
            where  x.ext_acct_no = y.agmt_id
                   and x.acct_seqno = y.acct_seqno) a
    LEFT   JOIN (select distinct pty_id,
                                 (case
                                   when pty_type = 'T28010' then
                                    pty_type
                                   else
                                    'T28020'
                                 end) pty_type
                 from   dwf.f_pty_table
                 where  end_dt = to_date('2999-12-31', 'YYYY-MM-DD')) g
    ON     a.cust_no = g.pty_id;
    
    
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID	29krh3fpfgzpf, child number 0
    -------------------------------------
    SELECT	  a.trans_org as 禄煤? FROM   (select	x.trans_org,
     x.ext_acct_no, 	       x.acct_seqno,		    y.agmt_id,
    	      x.cust_no 	from   (select	 *		   from
      dwf.f_evt_savr_bigtrans		  where  trans_date >=
    To_Date('2013-12-03', 'YYYY-MM-DD')			   AND
    trans_date <= TO_DATE('2014-03-05', 'YYYY-MM-DD')
     AND trans_org in			 (SELECT /*+ no_unnest*/
    t.Org_Id			     FROM   b_m_Sys_Branch t
    		 WHERE	t.Status = 1
    AND t.Dept_Flag != '2'				   CONNECT BY PRIOR
    t.Id = t.Parent_Id			       START  WITH t.Org_Id =
    10000)) x,		  (select ab.*, e.bus_name		   from
      (select *			    From   dwf.f_agt_savb_acctinfo_h
    		     where  start_dt <= TO_DATE('2014-01-05',
    'YYYY-MM-DD')
    
    Plan hash value: 1818178126
    
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation				   | Name		   | Starts | E-Rows | A-Rows |   A-Time   | Buffers | Reads  |  OMem |  1Mem | Used-Mem |
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT			   |			   |	  1 |	     |	  594K|00:00:53.87 |	1163K|	  780K|       |       | 	 |
    |*  1 |  FILTER 				   |			   |	  1 |	     |	  594K|00:00:53.87 |	1163K|	  780K|       |       | 	 |
    |*  2 |   HASH JOIN RIGHT OUTER 		   |			   |	  1 |	 489K|	  707K|00:00:43.97 |	 827K|	  780K|  1519K|  1519K| 1606K (0)|
    |*  3 |    TABLE ACCESS FULL			   | F_SAVC_BUSCODE	   |	  1 |	 400 |	  400 |00:00:00.01 |	  12 |	    0 |       |       | 	 |
    |*  4 |    HASH JOIN				   |			   |	  1 |	 489K|	  707K|00:00:43.02 |	 827K|	  780K|    56M|  6248K|   74M (0)|
    |*  5 |     HASH JOIN RIGHT OUTER		   |			   |	  1 |	 489K|	  815K|00:00:05.03 |	 242K|	  220K|    34M|  7428K|   34M (0)|
    |   6 |      VIEW				   |			   |	  1 |	 590K|	  584K|00:00:01.57 |   22022 |	    0 |       |       | 	 |
    |   7 |       HASH UNIQUE			   |			   |	  1 |	 590K|	  584K|00:00:01.42 |   22022 |	    0 |    41M|  6322K|   32M (0)|
    |*  8 |        TABLE ACCESS FULL		   | F_PTY_TABLE	   |	  1 |	 590K|	  588K|00:00:00.57 |   22022 |	    0 |       |       | 	 |
    |*  9 |      TABLE ACCESS FULL			   | F_EVT_SAVR_BIGTRANS   |	  1 |	 421K|	  815K|00:00:02.11 |	 220K|	  220K|       |       | 	 |
    |* 10 |     TABLE ACCESS FULL			   | F_AGT_SAVB_ACCTINFO_H |	  1 |	3280K|	 1172K|00:00:35.42 |	 585K|	  560K|       |       | 	 |
    |* 11 |   FILTER				   |			   |  55990 |	     |	54008 |00:00:09.14 |	 335K|	    0 |       |       | 	 |
    |* 12 |    CONNECT BY NO FILTERING WITH SW (UNIQUE)|			   |  55990 |	     |	  369K|00:00:08.96 |	 335K|	    0 |       |       | 	 |
    |  13 |     TABLE ACCESS FULL			   | B_M_SYS_BRANCH	   |  55990 |	  82 |	 4591K|00:00:02.17 |	 335K|	    0 |       |       | 	 |
    ------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter( IS NOT NULL)
       2 - access("F_AGT_SAVB_ACCTINFO_H"."SUBJ_CD"="E"."SUBJ_CD" AND "E"."TERM"=TO_NUMBER("F_AGT_SAVB_ACCTINFO_H"."TERM") AND
    	      "E"."BUS_CODE"=TO_NUMBER("F_AGT_SAVB_ACCTINFO_H"."BUS_CODE"))
       3 - filter("E"."SUBJ_CD" IS NOT NULL)
       4 - access("F_EVT_SAVR_BIGTRANS"."EXT_ACCT_NO"="F_AGT_SAVB_ACCTINFO_H"."AGMT_ID" AND
    	      "F_EVT_SAVR_BIGTRANS"."ACCT_SEQNO"="F_AGT_SAVB_ACCTINFO_H"."ACCT_SEQNO")
       5 - access("F_EVT_SAVR_BIGTRANS"."CUST_NO"="G"."PTY_ID")
       8 - filter("END_DT"=TO_DATE(' 2999-12-31 00:00:00', 'syyyy-mm-dd hh24:mi:ss'))
       9 - filter(("TRANS_DATE">=TO_DATE(' 2013-12-03 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "TRANS_DATE"<=TO_DATE(' 2014-03-05 00:00:00', 'syyyy-mm-dd
    	      hh24:mi:ss')))
      10 - filter(("END_DT">TO_DATE(' 2014-01-05 00:00:00', 'syyyy-mm-dd hh24:mi:ss') AND "START_DT"<=TO_DATE(' 2014-01-05 00:00:00', 'syyyy-mm-dd
    	      hh24:mi:ss')))
      11 - filter(("T"."ORG_ID"=:B1 AND "T"."STATUS"=1 AND "T"."DEPT_FLAG"<>'2'))
      12 - access("T"."PARENT_ID"=PRIOR NULL)
           filter(TO_NUMBER("T"."ORG_ID")=10000)
    
    
    58 rows selected.

  • 相关阅读:
    禁用aspx页面的客户端缓存
    水晶报表的自动换行(转)
    ORACLE锁的管理
    同时使用有线和无线
    Oracle系统表的查询
    Oracle中临时表的深入研究
    我的My Life Rate
    [学习笔记]c#Primer中文版命名空间
    出差兰州·火车上
    [学习笔记]c#Primer中文版类设计、static成员、const和readonly数据成员
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13352154.html
Copyright © 2020-2023  润新知