[英]Oracle Query Performance Optimization
I am currently working on optimizing the below query and it's taking more than 60 minutes to run.我目前正在优化以下查询,运行时间超过 60 分钟。 The dates provided in the query is substituted from variables which calculate the date during execution.
查询中提供的日期由计算执行期间日期的变量替换。 The goal is for this query to run within 10 minutes.
此查询的目标是在 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';
Below are the total number of rows for each of the tables used.以下是所用每个表的总行数。
All these tables reside in a master database, which is read only and I am not allowed to create any indexes to improve the performance.所有这些表都驻留在一个 master 数据库中,该数据库是只读的,我不允许创建任何索引来提高性能。 The only option is to use hints and play around with the query.
唯一的选择是使用提示并尝试查询。 Below is the current execution plan for the query above.
下面是上面查询的当前执行计划。
I am a novice when it comes to performance tuning and would appreciate if you could let me know if I should provide any other info regarding the tables, for you to make a suggestion on tuning the query.在性能调整方面,我是新手,如果您能让我知道我是否应该提供有关表的任何其他信息,以便您提出有关调整查询的建议,我将不胜感激。
Try below.试试下面。 In general you can think about optimization like i will explain:
一般来说,您可以像我将解释的那样考虑优化:
OR
and LIKE
statements if it is possible.OR
和LIKE
语句。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';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.