Oracle
 sql >> Base de données >  >> RDS >> Oracle

Optimisation des performances d'Oracle

Si j'ai bien compris, vous utilisez la sous-requête de corrélation pour trouver des lignes avec plus d'un exceptn_criteria_rtrn_val distinct évaluer. Si j'ai raison, il vaut mieux utiliser la fonction analytique :

select vw.registration_id as REGISTRATION_ID, vw.batch_id as BATCH_ID
from
 (select ss.registration_id as REGISTRATION_ID, ss.batch_id as BATCH_ID
        ,count(distinct sub_query.exceptn_criteria_rtrn_val) over(partition by ss.registration_id, ss.batch_id) as cnt
    from submtd_srvc PARTITION(SUBMTD_SRVC_821370) ss,
         (select a.exceptn_criteria_val, a.exceptn_criteria_rtrn_val
            from EXCEPTN_CRITERIA a, EXCEPTN_EXPRESSION b
           where a.EXCEPTN_EXPRESSION_ID = b.EXCEPTN_EXPRESSION_ID
             and b.EXCEPTN_EXPRESSION_NAME = 'NC_CUSTOM_REV_CAT'
             and b.IS_CURRENT_INDCTR = 1
             and a.IS_CURRENT_INDCTR = 1) sub_query
   where ss.REVENUE_CD = sub_query.exceptn_criteria_val
     and ss.batch_id = 821370) vw
where cnt > 1
Order By vw.Registration_Id, vw.batch_id;