クエリの読み込みが 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