sqloracle-databaseperformanceoracle-apps

How to tune this query?


I am calculating the resource cost:

        SELECT NVL(sum(WT.TRANSACTION_QUANTITY* WTA.RATE_OR_AMOUNT),0) 
        --    INTO l_resource_cost
        FROM APPS.WIP_TRANSACTION_ACCOUNTS WTA, APPS.WIP_TRANSACTIONS WT
        WHERE WTA.TRANSACTION_ID = WT.TRANSACTION_ID
        AND WTA.ORGANIZATION_ID = WT.ORGANIZATION_ID
        AND WTA.ACCOUNTING_LINE_TYPE =7
        AND WTA.WIP_ENTITY_ID = 1757957
        AND wt.operation_seq_num = 10;

The tables are Oracle ebs WIP tables, the data is correct but this is need to be executed for thousands of records.

How can I tune it?

can I attache the explain plan here?


Solution

  • First, learn to use proper explicit JOIN syntax. Simple rule: Never use commas in the FROM clause:

    SELECT COALESCE(sum(WT.TRANSACTION_QUANTITY * WTA.RATE_OR_AMOUNT), 0) 
            --    INTO l_resource_cost
    FROM APPS.WIP_TRANSACTION_ACCOUNTS WTA JOIN
         APPS.WIP_TRANSACTIONS WT
         ON WTA.TRANSACTION_ID = WT.TRANSACTION_ID AND
            WTA.ORGANIZATION_ID = WT.ORGANIZATION_ID
    WHERE WTA.ACCOUNTING_LINE_TYPE = 7 AND WTA.WIP_ENTITY_ID = 1757957 AND
          wt.operation_seq_num = 10;
    

    Indexes will help the query. I would recommend: