oracle查询性能优化

zynd9foi  于 2021-07-29  发布在  Java
关注(0)|答案(1)|浏览(567)

我目前正在优化下面的查询,运行时间超过60分钟。查询中提供的日期由执行期间计算日期的变量替换。目标是在10分钟内运行此查询。

SELECT
   clm.clcl_payee_pr_id, 
   clm.sbsb_ck, 
   clm.clcl_id, 
   clm.meme_ck, 
   clm.clcl_paid_dt, 
   Row_number() 
     OVER ( 
       ORDER BY clm.clcl_payee_pr_id, clm.sbsb_ck, clm.clcl_id) AS reccount
FROM cmc_mepe_prcs_elig MEPE 
INNER JOIN cmc_meme_member MEME 
        ON MEPE.meme_ck = MEME.meme_ck 
           AND MEPE.grgr_ck = '41' 
INNER JOIN cmc_mepr_prim_prov MEPR 
        ON MEPE.meme_ck = MEPR.meme_ck 
           AND MEPR.grgr_ck = '41' 
INNER JOIN cmc_sbsb_subsc SBSB 
        ON MEME.sbsb_ck = SBSB.sbsb_ck 
           AND SBSB. grgr_ck = '41' 
INNER JOIN cmc_prpr_prov PROV 
        ON MEPR.prpr_id = PROV.prpr_id 
INNER JOIN cmc_prer_relation PRER 
        ON PRER.prpr_id = MEPR.prpr_id 
           AND PRER.prer_prpr_entity = 'I' 
           AND PRER.prer_prpr_id IN ( '02549455' ) 
INNER JOIN cmc_clcl_claim CLM 
        ON MEME.meme_ck = CLM.meme_ck 
           AND CLM.clcl_prpr_id_pcp = MEPR.prpr_id 
INNER JOIN cmc_prpr_prov PRPR 
        ON CLM.prpr_id = PRPR.prpr_id 
INNER JOIN cmc_plds_plan_desc PLDS 
        ON MEPE.cspi_id = PLDS.cspi_id 
INNER JOIN cmc_pdds_prod_desc PDDS 
        ON MEPE.pdpd_id = PDDS.pdpd_id 
WHERE  MEPE.mepe_elig_ind = 'Y' 
AND CLM.clcl_low_svc_dt BETWEEN MEPE.mepe_eff_dt AND MEPE.mepe_term_dt 
AND CLM.clcl_low_svc_dt BETWEEN MEPR.mepr_eff_dt AND MEPR.mepr_term_dt 
AND CLM.clcl_cur_sts = '02' 
AND CLM.clcl_cl_type = 'M' 
AND CLM.clcl_cl_sub_type = 'H' 
AND CLM.grgr_ck IN ( 41 ) 
AND ( PLDS.plds_desc LIKE '%risk%' OR PDDS.pdds_desc LIKE '%risk%' ) 
AND CLM.clcl_paid_dt BETWEEN  '24-APR-19 12.00.00.000000 AM' AND '30-APR-19 11.59.59.997000 PM';

下面是所使用的每个表的总行数。
cmc\u mepe\u prcs\u elig:103974973
cmc成员:22433154
cmc\u mepr\u prim\u省:53498452
cmc\ sbsb\ subsc:22433154
军委批准:5266062
cmc\u prer\u关系:4735086
cmc\ clcl\ U索赔:897405800
计划描述:19122
cmc\ pdds\产品描述:4776
所有这些表都驻留在主数据库中,主数据库是只读的,不允许我创建任何索引来提高性能。唯一的选择是使用提示并处理查询。下面是上述查询的当前执行计划。

在性能调优方面,我是一个新手,如果您能告诉我是否应该提供有关表的任何其他信息,以便您对优化查询提出建议,我将不胜感激。

ruyhziif

ruyhziif1#

试试下面。一般来说,你可以像我将要解释的那样思考优化:
尽量避免 OR 以及 LIKE 如果可能的话。
构造连接时,不应与两个以上的表进行交互(clm同时与meme和mepr连接)。如果您需要联接这3个表,请尝试添加另一个具有其他别名(如clm2)的联接,然后将此新别名与其他表联接。)

SELECT CLM.CLCL_PAYEE_PR_ID,
       CLM.SBSB_CK,
       CLM.CLCL_ID,
       CLM.MEME_CK,
       CLM.CLCL_PAID_DT,
       ROW_NUMBER ()
          OVER (ORDER BY CLM.CLCL_PAYEE_PR_ID, CLM.SBSB_CK, CLM.CLCL_ID)
          AS RECCOUNT
  FROM CMC_MEPE_PRCS_ELIG MEPE
       INNER JOIN CMC_PLDS_PLAN_DESC PLDS ON MEPE.CSPI_ID = PLDS.CSPI_ID
       INNER JOIN CMC_PDDS_PROD_DESC PDDS ON MEPE.PDPD_ID = PDDS.PDPD_ID
       INNER JOIN CMC_MEME_MEMBER MEME
          ON MEPE.MEME_CK = MEME.MEME_CK AND MEPE.GRGR_CK = '41'
       INNER JOIN CMC_SBSB_SUBSC SBSB
          ON MEME.SBSB_CK = SBSB.SBSB_CK AND SBSB.GRGR_CK = '41'
       INNER JOIN CMC_MEPR_PRIM_PROV MEPR
          ON MEPE.MEME_CK = MEPR.MEME_CK AND MEPR.GRGR_CK = '41'
       INNER JOIN CMC_PRPR_PROV PROV ON MEPR.PRPR_ID = PROV.PRPR_ID
       INNER JOIN CMC_PRER_RELATION PRER
          ON PRER.PRPR_ID = MEPR.PRPR_ID AND PRER.PRER_PRPR_ENTITY = 'I'
       INNER JOIN CMC_PRPR_PROV PRPR ON CLM.PRPR_ID = PRPR.PRPR_ID
       INNER JOIN CMC_CLCL_CLAIM CLM
          ON     MEME.MEME_CK = CLM.MEME_CK
--             AND CLM.CLCL_PRPR_ID_PCP = MEPR.PRPR_ID
 WHERE     MEPE.MEPE_ELIG_IND = 'Y'
       AND CLM.CLCL_LOW_SVC_DT BETWEEN MEPE.MEPE_EFF_DT AND MEPE.MEPE_TERM_DT
       AND CLM.CLCL_LOW_SVC_DT BETWEEN MEPR.MEPR_EFF_DT AND MEPR.MEPR_TERM_DT
       AND CLM.CLCL_CUR_STS = '02'
       AND CLM.CLCL_CL_TYPE = 'M'
       AND CLM.CLCL_CL_SUB_TYPE = 'H'
       AND CLM.GRGR_CK IN (41)
--       AND (PLDS.PLDS_DESC LIKE '%risk%' OR PDDS.PDDS_DESC LIKE '%risk%')
       AND CLM.CLCL_PAID_DT BETWEEN '24-APR-19 12.00.00.000000 AM'
                                AND '30-APR-19 11.59.59.997000 PM'
       AND PRER.PRER_PRPR_ID = '02549455';

相关问题