我目前正在优化下面的查询,运行时间超过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
所有这些表都驻留在主数据库中,主数据库是只读的,不允许我创建任何索引来提高性能。唯一的选择是使用提示并处理查询。下面是上述查询的当前执行计划。
在性能调优方面,我是一个新手,如果您能告诉我是否应该提供有关表的任何其他信息,以便您对优化查询提出建议,我将不胜感激。
1条答案
按热度按时间ruyhziif1#
试试下面。一般来说,你可以像我将要解释的那样思考优化:
尽量避免
OR
以及LIKE
如果可能的话。构造连接时,不应与两个以上的表进行交互(clm同时与meme和mepr连接)。如果您需要联接这3个表,请尝试添加另一个具有其他别名(如clm2)的联接,然后将此新别名与其他表联接。)