好久没写博客了,今天写下存储过程表之间的关联性能问题
(一)SELECT DISTINCT COUNT(1)
FROM CR_LN_AR_SMY LAS --贷款合约汇总
LEFT JOIN CR_AR_X_MRTG AXM --中间表
ON LAS.CTR_NBR = AXM.CTR_AR_ID
LEFT JOIN CR_GUR_CTR_AR GCA --贷款担保合同账户
ON GCA.GUR_CTR_AR_ID = AXM.GUR_CTR_AR_ID
LEFT JOIN CR_MRTG_INF MI --担保物信息
ON MI.MRTG_ID = AXM.MRTG_ID
LEFT JOIN CR_IDV I --个人客户信息
ON I.IDV_IP_ID = LAS.CST_ID
WHERE LAS.LN_DRDN_DT = --去重
(SELECT MAX(LN_DRDN_DT)
FROM CR_LN_AR_SMY LAS1
WHERE LAS.CTR_NBR = LAS1.CTR_NBR)
AND LAS.OVERDUEDAYS >90
(二)SELECT COUNT(1)
FROM CR_LN_AR_SMY LAS --贷款合约汇总
/*三张表通过中间表整合到一块在关联*/
LEFT JOIN (SELECT TT.ACAI TACI
FROM (SELECT AXM.MRTG_ID AMI, AXM.CTR_AR_ID ACAI --中间表的
FROM CR_AR_X_MRTG AXM --中间表
LEFT JOIN CR_GUR_CTR_AR GCA --担保合同账户
ON GCA.GUR_CTR_AR_ID = AXM.GUR_CTR_AR_ID) TT --担保合同账户.担保合同账户号=中间表.担保合同账户号
LEFT JOIN CR_MRTG_INF MI--担保物表
ON MI.MRTG_ID = TT.AMI) TT1 --担保物表.担保物编号=TT.AMI
ON LAS.CTR_NBR = TT1.TACI
LEFT JOIN CR_IDV I --个人客户信息
ON LAS.CST_ID = I.IDV_IP_ID
WHERE LAS.LN_DRDN_DT = --去重
(SELECT MAX(LN_DRDN_DT)
FROM CR_LN_AR_SMY LAS1
WHERE LAS.CTR_NBR = LAS1.CTR_NBR)
AND LAS.OVERDUEDAYS > 90
这两个我在Oracle里测试出来的数据是一样的