문제

Below for each loop takes more time and i cant able to trace index usage using XREF as the table uses Oracle Schema.Please Help me.

Need to generate report for different Report Type ( Report type is the input parameter in my code ).Single report type may contain more than 50,000 records how to access all the record within minute.Index detail also mentioned below for each loop.

FOR EACH Report 
      FIELDS(EXTRACTDATE STATUS MailingType ReportType ReportNumber 
             RequestID CustID)
      WHERE Report.EXTRACTDATE < Today
        AND Report.ReportType = 'Customer Report' 
        AND Report.STATUS = 'Pending' 
        AND (Report.MailingType  = "LETTER"
         OR Report.MailingType  = "Mail") NO-LOCK:

             < Statements >
                 .
                 .

END.

**Index Detail**

CREATE INDEX "TYPE_IDX1" ON "Report" ("EXTRACTDATE" DESC, "ReportTYPE", "STATUS", "MailingTYPE", "PROGRESS_RECID") 

CREATE INDEX "REQ_IDX1" ON "Report" ("REQUESTID", "PROGRESS_RECID") 

CREATE INDEX "RTTYP_IDX1" ON "Report" ("ReportTYPE","PROGRESS_RECID") 
도움이 되었습니까?

해결책

The "OR" at the end will slow things down considerably - the AVM does better if you split it up into two sets of AND statements and OR the result, like so:

WHERE (Report.EXTRACTDATE < Today
    AND Report.ReportType = 'Customer Report' 
    AND Report.STATUS = 'Pending' 
    AND Report.MailingType  = "LETTER") 

            OR 

      (Report.EXTRACTDATE < Today
    AND Report.ReportType = 'Customer Report' 
    AND Report.STATUS = 'Pending' 
    AND Report.MailingType  = "Mail") 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top