• 再次遭遇笛卡尔积


    改为MERGE /*+ordered*/ INTO YJBZH_GRXDFHZMXJL GRXDFHZMXJL USING ( SELECT 
    A.AGMT_ID AS AGMT_ID, B.CUST_NAME AS CUST_NAME FROM 
    DWF.F_AGT_CADB_BOOK_H A, DWF.F_AGT_SAVB_BASICINFO_H B WHERE A.START_DT 
    <= TO_DATE(:B1 ,'yyyy-mm-dd') AND A.END_DT > TO_DATE(:B1 ,'yyyy-mm-dd') 
    AND B.START_DT <= TO_DATE(:B1 ,'yyyy-mm-dd') AND B.END_DT > TO_DATE(:B1 
    ,'yyyy-mm-dd') AND A.MASTER_CARD_NO = B.AGMT_ID ) SAVB_BASICINFO ON ( 
    RTRIM(GRXDFHZMXJL.DFZH) = SAVB_BASICINFO.AGMT_ID AND CJRQ = 
    TO_CHAR(TO_DATE(:B1 , 'YYYY-MM-DD'),'yyyymmdd') ) WHEN MATCHED THEN 
    UPDATE SET GRXDFHZMXJL.DFHM = SAVB_BASICINFO.CUST_NAME
    
    加了/*+order*/ 还是出现了笛卡尔积,不得不再加hints
    
    SQL_ID  5wyfn0trgu5rx, child number 0
    -------------------------------------
    MERGE /*+  ORDERED  use_hash(A B) use_hash(A GRXDFHZMXJL)*/ INTO 
    YJBZH_GRXDFHZMXJL GRXDFHZMXJL USING ( SELECT A.AGMT_ID AS AGMT_ID, 
    B.CUST_NAME AS CUST_NAME FROM DWF.F_AGT_CADB_BOOK_H A, 
    DWF.F_AGT_SAVB_BASICINFO_H B WHERE A.START_DT <= TO_DATE(:B1 
    ,'yyyy-mm-dd') AND A.END_DT > TO_DATE(:B1 ,'yyyy-mm-dd') AND B.START_DT 
    <= TO_DATE(:B1 ,'yyyy-mm-dd') AND B.END_DT > TO_DATE(:B1 ,'yyyy-mm-dd') 
    AND A.MASTER_CARD_NO = B.AGMT_ID ) SAVB_BASICINFO ON ( 
    RTRIM(GRXDFHZMXJL.DFZH) = SAVB_BASICINFO.AGMT_ID AND CJRQ = 
    TO_CHAR(TO_DATE(:B1 , 'YYYY-MM-DD'),'yyyymmdd') ) WHEN MATCHED THEN 
    UPDATE SET GRXDFHZMXJL.DFHM = SAVB_BASICINFO.CUST_NAME
     
    Plan hash value: 2400855618
     
    --------------------------------------------------------------------------------------------------------
    | Id  | Operation             | Name                   | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    --------------------------------------------------------------------------------------------------------
    |   0 | MERGE STATEMENT       |                        |       |       |       |   125K(100)|          |
    |   1 |  MERGE                | YJBZH_GRXDFHZMXJL      |       |       |       |            |          |
    |   2 |   VIEW                |                        |       |       |       |            |          |
    |*  3 |    HASH JOIN          |                        |     1 |  1862 |       |   125K  (2)| 00:25:01 |
    |*  4 |     TABLE ACCESS FULL | YJBZH_GRXDFHZMXJL      |     1 |  1762 |       | 12948   (1)| 00:02:36 |
    |*  5 |     HASH JOIN         |                        |    11M|  1074M|   374M|   112K  (2)| 00:22:25 |
    |*  6 |      TABLE ACCESS FULL| F_AGT_CADB_BOOK_H      |  5951K|   306M|       | 69245   (2)| 00:13:51 |
    |*  7 |      TABLE ACCESS FULL| F_AGT_SAVB_BASICINFO_H |  2120K|    93M|       | 18256   (2)| 00:03:40 |
    --------------------------------------------------------------------------------------------------------
     
    Predicate Information (identified by operation id):
    ---------------------------------------------------
     
       3 - access("A"."AGMT_ID"=RTRIM("GRXDFHZMXJL"."DFZH"))
       4 - filter("CJRQ"=TO_CHAR(TO_DATE(:B1,'YYYY-MM-DD'),'yyyymmdd'))
       5 - access("A"."MASTER_CARD_NO"="B"."AGMT_ID")
       6 - filter(("A"."MASTER_CARD_NO" IS NOT NULL AND "A"."START_DT"<=TO_DATE(:B1,'yyyy-mm-dd') 
                  AND "A"."END_DT">TO_DATE(:B1,'yyyy-mm-dd')))
       7 - filter(("B"."START_DT"<=TO_DATE(:B1,'yyyy-mm-dd') AND 
                  "B"."END_DT">TO_DATE(:B1,'yyyy-mm-dd')))
     
    
    
    
    
    
    

  • 相关阅读:
    C# 中Async 和 Await 的用法,异步等待执行结果
    C# 事件发布和订阅
    C# 多线程使用信号量控制处理效率,统计活动中的线程
    C# 委托和泛型委托示例
    C# 数据库批量插入数据之 —— SqlBulkCopy、表值参数
    WinRar DOS命令大全带详细参数rar/zip/7z压缩文件解密
    Magic.Orm 基于C#的ORM框架,支持Sql Server/MySql/Oracle/Access/Sqlite等数据库,支持Lambda表达式快速上手0难度
    SqlServer使用SqlBulkCopy批量新增和更新数据,快速高效
    Flink内存模型
    Linux 查找替换
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13352379.html
Copyright © 2020-2023  润新知