有没有完美的解释为什么我的查询加载速度会慢到 100 秒?
是否有任何可能的重建以使我的查询加载更快?
SELECT IF(IMI.BRANCH_CODE IS NOT NULL AND IMI.PRODCODE IS NOT NULL AND IMI.POLNO IS NOT NULL,"Y","N") as STATUS,
NOW(),ICH.CLAIM_NO,ICH.BRANCH_CODE,
ICH.PRODUCT_TYPE,ICH.POLICY_NO,ICH.ASSURED_NAME,
ICH.AGENT_NO,ICH.INCEPTION_DT,ICH.EXPIRY_DT,
ICH.DT_REPORTED,IMI.BASIC_PREMIUM,ICH.CLAIM_STATUS,
IRPD.CLAIM_RESERVE,IRPD.TOTAL_AMT_RECOMMENDED,IRPD.DT_RECOMMENDED,
IMI.UW_YEAR,ICDO.PLATE_NO,ICDO.CHASSIS_NO,
ICDO.MOTOR_NO,IMI.LOCATION,IMI.RISKNO,IMI.SEQNO
FROM `ICATS_CLAIM_HEADER` ICH
LEFT JOIN `ICATS_CLAIM_DETAILS_OD` ICDO ON ICH.CLAIM_NO = ICDO.CLAIM_NO
LEFT JOIN `ICATS_MULTIPLE_LOSS` IML ON ICH.CLAIM_NO = IML.CLAIM_NO
LEFT JOIN (SELECT * FROM ICATS_RESERVE_PAYMENT_DETAILS
WHERE DATEDIFF(NOW(),DT_RECOMMENDED)=1 OR DATEDIFF(NOW(),RESERVE_DT)=1) IRPD
ON ICH.CLAIM_NO = IRPD.CLAIM_NO
LEFT JOIN (SELECT POLNO,PRODCODE,BRANCH_CODE,MAX(SEQNO)as SEQNO FROM IWRITE_MOTOR_INFO
GROUP BY POLNO,PRODCODE,BRANCH_CODE) IM
ON ICH.POLICY_NO = IM.POLNO AND ICH.BRANCH_CODE = IM.BRANCH_CODE AND ICH.PRODUCT_TYPE = IM.PRODCODE
JOIN IWRITE_MOTOR_INFO IMI
ON IM.POLNO = IMI.POLNO AND IM.PRODCODE = IMI.PRODCODE AND IM.BRANCH_CODE = IMI.BRANCH_CODE AND IM.SEQNO = IMI.SEQNO
WHERE (DATEDIFF(CURDATE(),ICH.CLAIM_STATUS_DT)=1
OR DATEDIFF(NOW(),ICDO.TRANSACTION_DT)=1
OR DATEDIFF(NOW(),IRPD.RESERVE_DT)=1
OR DATEDIFF(NOW(),IRPD.DT_RECOMMENDED)=1)
ORDER BY ICH.CLAIM_NO,IRPD.SEQUENCE_NO ASC
总的来说,这里是我的整个查询。事实上,在检查所有要插入的数据时,我的查询似乎加载慢到 100 秒。
INSERT INTO `ICATS_IINSURE_CLAIM_HEADER`(IINSURE_EXIST,RECORD_CREATED_DT,CLAIM_NUMBER,BRANCH_CODE,PRODCODE,POLNO,ASSURED_NAME1,
AGENT_CODE,INCEPTION,EXPIRY,DATE_REPORTED,BASIC_PREMIUM,
CLAIM_STATUS,RESERVE_AMOUNT,CLAIMS_PAID_AMOUNT,
DATE_RECOMMEND_PAYMENT,UW_YEAR,PLATE_NUMBER,
CHASSIS,ENGINE,LOCATION,RISKNO,SEQ)
SELECT IF(IMI.BRANCH_CODE IS NOT NULL AND IMI.PRODCODE IS NOT NULL AND IMI.POLNO IS NOT NULL,"Y","N") as STATUS,
NOW(),ICH.CLAIM_NO,ICH.BRANCH_CODE,
ICH.PRODUCT_TYPE,ICH.POLICY_NO,ICH.ASSURED_NAME,
ICH.AGENT_NO,ICH.INCEPTION_DT,ICH.EXPIRY_DT,
ICH.DT_REPORTED,IMI.BASIC_PREMIUM,ICH.CLAIM_STATUS,
IRPD.CLAIM_RESERVE,IRPD.TOTAL_AMT_RECOMMENDED,IRPD.DT_RECOMMENDED,
IMI.UW_YEAR,ICDO.PLATE_NO,ICDO.CHASSIS_NO,
ICDO.MOTOR_NO,IMI.LOCATION,IMI.RISKNO,IMI.SEQNO
FROM `ICATS_CLAIM_HEADER` ICH
LEFT JOIN `ICATS_CLAIM_DETAILS_OD` ICDO ON ICH.CLAIM_NO = ICDO.CLAIM_NO
LEFT JOIN `ICATS_MULTIPLE_LOSS` IML ON ICH.CLAIM_NO = IML.CLAIM_NO
LEFT JOIN (SELECT * FROM ICATS_RESERVE_PAYMENT_DETAILS
WHERE DATEDIFF(NOW(),DT_RECOMMENDED)=1 OR DATEDIFF(NOW(),RESERVE_DT)=1) IRPD
ON ICH.CLAIM_NO = IRPD.CLAIM_NO
LEFT JOIN (SELECT POLNO,PRODCODE,BRANCH_CODE,MAX(SEQNO)as SEQNO FROM IWRITE_MOTOR_INFO
GROUP BY POLNO,PRODCODE,BRANCH_CODE) IM
ON ICH.POLICY_NO = IM.POLNO AND ICH.BRANCH_CODE = IM.BRANCH_CODE AND ICH.PRODUCT_TYPE = IM.PRODCODE
JOIN IWRITE_MOTOR_INFO IMI
ON IM.POLNO = IMI.POLNO AND IM.PRODCODE = IMI.PRODCODE AND IM.BRANCH_CODE = IMI.BRANCH_CODE AND IM.SEQNO = IMI.SEQNO
WHERE (DATEDIFF(CURDATE(),ICH.CLAIM_STATUS_DT)=1
OR DATEDIFF(NOW(),ICDO.TRANSACTION_DT)=1
OR DATEDIFF(NOW(),IRPD.RESERVE_DT)=1
OR DATEDIFF(NOW(),IRPD.DT_RECOMMENDED)=1)
ORDER BY ICH.CLAIM_NO,IRPD.SEQUENCE_NO ASC