• FILTER 索引扫描多次


    explain plan for SELECT tcnt,
           rn,
           CustomerID,
           CustomerName,
           CustomerType,
           CertType,
           CertID,
           MFCustomerID,
           MCCustomerID,
           ManageOrgName,
           ManageUserName,
           ManageUserID,
           Private,
           Isresure,
           Balance
      FROM (SELECT COUNT(1) OVER() AS tcnt,
                   ROWNUM AS rn,
                   O.CustomerID,
                   O.CustomerName,
                   O.CustomerType,
                   O.CertType,
                   O.CertID,
                   O.MFCustomerID,
                   O.MCCustomerID,
                   GETMANAGEUSERID(O.CustomerID) AS ManageUserID,
                   GETMANAGEORGNAME(O.CustomerID) AS ManageOrgName,
                   GETMANAGEUSERNAME(O.CustomerID) AS ManageUserName,
                   O.Private,
                   O.Isresure,
                   GETCUSTOMERBALANCE3(O.CustomerID) AS Balance
              FROM CUSTOMER_INFO O
             WHERE 1 = 1
               AND (EXISTS (SELECT II.CustomerID
                              FROM IND_INFO II
                             WHERE II.UpdateDate = '2019/10/23'
                               AND II.UpdateUserID = '991735'
                               AND O.CustomerID = II.CustomerID
                            UNION
                            SELECT EI.CustomerID
                              FROM ENT_INFO EI
                             WHERE EI.UpdateDate = '2019/10/23'
                               AND EI.UpdateUserID = '991735'
                               AND O.CustomerID = EI.CustomerID))
               AND NVL(O.belongCorporaTion, '9999') = '9999')
     WHERE rn BETWEEN 1 AND 10;
    select * from table(dbms_xplan.display());
    
    PLAN_TABLE_OUTPUT
    Plan hash value: 2649621158
     
    ---------------------------------------------------------------------------------------------------
    | Id  | Operation                         | Name          | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                  |               |     1 |  6238 |    28M (25)| 00:18:19 |
    |*  1 |  VIEW                             |               |     1 |  6238 |    28M (25)| 00:18:19 |
    |   2 |   WINDOW BUFFER                   |               |     1 |    84 |    28M (25)| 00:18:19 |
    |   3 |    COUNT                          |               |       |       |            |          |
    |*  4 |     FILTER                        |               |       |       |            |          |
    |*  5 |      TABLE ACCESS FULL            | CUSTOMER_INFO |  3518K|   281M| 18056   (1)| 00:00:01 |
    |   6 |      SORT UNIQUE                  |               |     2 |   120 |     8  (25)| 00:00:01 |
    |   7 |       UNION-ALL                   |               |       |       |            |          |
    |*  8 |        TABLE ACCESS BY INDEX ROWID| IND_INFO      |     1 |    29 |     3   (0)| 00:00:01 |
    |*  9 |         INDEX UNIQUE SCAN         | PK_IND_INFO   |     1 |       |     2   (0)| 00:00:01 |
    |* 10 |        TABLE ACCESS BY INDEX ROWID| ENT_INFO      |     1 |    31 |     3   (0)| 00:00:01 |
    |* 11 |         INDEX UNIQUE SCAN         | PK_ENT_INFO   |     1 |       |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       1 - filter("RN">=1 AND "RN"<=10)
       4 - filter( EXISTS ( (SELECT "II"."CUSTOMERID" FROM "IND_INFO" "II" WHERE 
                  "II"."CUSTOMERID"=:B1 AND "II"."UPDATEUSERID"='991735' AND 
                  "II"."UPDATEDATE"='2019/10/23')UNION (SELECT "EI"."CUSTOMERID" FROM "ENT_INFO" "EI" WHERE 
                  "EI"."CUSTOMERID"=:B2 AND "EI"."UPDATEUSERID"='991735' AND 
                  "EI"."UPDATEDATE"='2019/10/23')))
       5 - filter(NVL("O"."BELONGCORPORATION",'9999')='9999')
       8 - filter("II"."UPDATEUSERID"='991735' AND "II"."UPDATEDATE"='2019/10/23')
       9 - access("II"."CUSTOMERID"=:B1)
      10 - filter("EI"."UPDATEUSERID"='991735' AND "EI"."UPDATEDATE"='2019/10/23')
      11 - access("EI"."CUSTOMERID"=:B1)
    
      
      
    SQL> select * from table(dbms_xplan.display_cursor(null,null,'ALLSTATS LAST'));
    
    PLAN_TABLE_OUTPUT
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    SQL_ID	f4zvxt88gr994, child number 0
    -------------------------------------
    SELECT tcnt,	    rn,        CustomerID,	  CustomerName,
    CustomerType,	     CertType,	      CertID,	     MFCustomerID,
      MCCustomerID,        ManageOrgName,	     ManageUserName,
    ManageUserID,	     Private,	     Isresure,	      Balance	FROM
    (SELECT COUNT(1) OVER() AS tcnt,		ROWNUM AS rn,
         O.CustomerID,		  O.CustomerName,
    O.CustomerType, 	       O.CertType,		  O.CertID,
    	   O.MFCustomerID,		  O.MCCustomerID,
     GETMANAGEUSERID(O.CustomerID) AS ManageUserID,
    GETMANAGEORGNAME(O.CustomerID) AS ManageOrgName,
    GETMANAGEUSERNAME(O.CustomerID) AS ManageUserName,
    O.Private,		  O.Isresure,
    GETCUSTOMERBALANCE3(O.CustomerID) AS Balance	       FROM
    CUSTOMER_INFO O 	 WHERE 1 = 1		AND (EXISTS (SELECT
    II.CustomerID				FROM IND_INFO II
    
    Plan hash value: 2649621158
    
    -------------------------------------------------------------------------------------------------------------------------------------------------
    | Id  | Operation			  | Name	  | Starts | E-Rows | A-Rows |	 A-Time   | Buffers | Reads  |	OMem |	1Mem | Used-Mem |
    -------------------------------------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT		  |		  |	 1 |	    |	  10 |00:01:01.57 |	 20M|  18924 |	     |	     |		|
    |*  1 |  VIEW				  |		  |	 1 |	  1 |	  10 |00:01:01.57 |	 20M|  18924 |	     |	     |		|
    |   2 |   WINDOW BUFFER 		  |		  |	 1 |	  1 |	  18 |00:01:01.50 |	 20M|  18895 |	4096 |	4096 | 4096  (0)|
    |   3 |    COUNT			  |		  |	 1 |	    |	  18 |00:01:01.50 |	 20M|  18895 |	     |	     |		|
    |*  4 |     FILTER			  |		  |	 1 |	    |	  18 |00:01:01.50 |	 20M|  18895 |	     |	     |		|
    |*  5 |      TABLE ACCESS FULL		  | CUSTOMER_INFO |	 1 |   3518K|	3574K|00:00:02.39 |   66444 |	   0 |	     |	     |		|
    |   6 |      SORT UNIQUE		  |		  |   3574K|	  2 |	  18 |00:00:56.23 |	 20M|  18895 |	2048 |	2048 |		|
    |   7 |       UNION-ALL 		  |		  |   3574K|	    |	  18 |00:00:52.23 |	 20M|  18895 |	     |	     |		|
    |*  8 |        TABLE ACCESS BY INDEX ROWID| IND_INFO	  |   3574K|	  1 |	  17 |00:00:35.99 |	 13M|  18895 |	     |	     |		|
    |*  9 | 	INDEX UNIQUE SCAN	  | PK_IND_INFO   |   3574K|	  1 |	3267K|00:00:13.16 |	 10M|	   1 |	     |	     |		|
    |* 10 |        TABLE ACCESS BY INDEX ROWID| ENT_INFO	  |   3574K|	  1 |	   1 |00:00:08.47 |    6750K|	   0 |	     |	     |		|
    |* 11 | 	INDEX UNIQUE SCAN	  | PK_ENT_INFO   |   3574K|	  1 |	 307K|00:00:05.71 |    6441K|	   0 |	     |	     |		|
    -------------------------------------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter(("RN">=1 AND "RN"<=10))
       4 - filter( IS NOT NULL)
       5 - filter(NVL("O"."BELONGCORPORATION",'9999')='9999')
       8 - filter(("II"."UPDATEUSERID"='991735' AND "II"."UPDATEDATE"='2019/10/23'))
       9 - access("II"."CUSTOMERID"=:B1)
      10 - filter(("EI"."UPDATEUSERID"='991735' AND "EI"."UPDATEDATE"='2019/10/23'))
      11 - access("EI"."CUSTOMERID"=:B1)
    
    
    48 rows selected.
    
    
    
  • 相关阅读:
    vuejs 组件通讯
    导出pdf
    css 鼠标选中内容背景色
    console.log() 字体颜色
    使用cross-env解决跨平台设置NODE_ENV的问题
    Visual Studio动态生成版权信息(VS2015,VS2010,VS2008)
    程序员常用工具汇总
    存储过程分页
    oracle全表扫描
    CDM常用命令
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348672.html
Copyright © 2020-2023  润新知