+ Reply to Thread + Post New Thread
Results 1 to 10 of 10
  1. #1
    grantie's Avatar
    grantie is offline Junior Member
    Join Date
    30 Nov 2009
    Posts
    6
    Say Thanks
    0
    Thanked 0 Times in 0 Posts
    Documents
    0
    Uploads
    0

    Default Query Performance Using PO and AP tables

    Hello. I'm new to this forum (and to Oracle Apps) so please be gentle.

    I'm writing a query agains PO_Headers, PO_Lines, PO_Line_Locations, PO_Line_Distributions, AP_Invoice_Distributions and AP_Invoices. I am putting criteria in against Accounting_Date (say for a month). I think my query is correct with respect to joins and the output I'm getting looks good. However, performance is terrible. It has taken more than an hour. Does anyone have any tips or clues as to what I should look for to try and improve this?

    I won't post the SQL here unless I get a kind soul who is able and willing to help me .

    Thanks in advance
    Last edited by grantie; 01-13-2010 at 11:55 AM.

  2.    Club-Oracle Complementary E-Books and Magazines
    Get your free Complementary Copy of Oracle Magazine

    You can also browse the Free Magazines and E-Books section to see the complete list of free magazines, e-books and Whitepapers.

  3. #2
    Sadik's Avatar
    Sadik is offline Administrator
    Join Date
    03 Aug 2008
    Location
    Kolkata, India
    Posts
    1,184
    Say Thanks
    7
    Thanked 83 Times in 54 Posts
    Documents
    4
    Uploads
    2

    Default Re: Query Performance Using PO and AP tables

    Hello Grantie...

    I would like to help, can I see the code please...
    Learn Oracle with Oracle forum. Check out The Technology Blog

  4. #3
    grantie's Avatar
    grantie is offline Junior Member
    Join Date
    30 Nov 2009
    Posts
    6
    Say Thanks
    0
    Thanked 0 Times in 0 Posts
    Documents
    0
    Uploads
    0

    Default Re: Query Performance Using PO and AP tables

    Hi Sadik. Thank you.

    Code sql:
    SELECT
      PO.PO_HEADERS_ALL.ATTRIBUTE1,
      PO.PO_HEADERS_ALL.ATTRIBUTE2,
      PO.PO_VENDORS.VENDOR_NAME,
      PO.PO_VENDOR_SITES_ALL.ZIP,
      PO.PO_HEADERS_ALL.SEGMENT1,
      PO.PO_LINES_ALL.LINE_NUM,
      PO.PO_LINES_ALL.ATTRIBUTE13,
      PO.PO_LINE_LOCATIONS_ALL.CANCEL_FLAG,
      PO.PO_LINE_LOCATIONS_ALL.CLOSED_CODE,
      PO.PO_LINES_ALL.ITEM_DESCRIPTION,
      PO.PO_LINES_ALL.UNIT_MEAS_LOOKUP_CODE,
      PO.PO_HEADERS_ALL.CURRENCY_CODE,
      nvl(PO.PO_HEADERS_ALL.RATE,1),
      nvl(AP.AP_INVOICE_DISTRIBUTIONS_ALL.EXCHANGE_RATE,1),
      PO.PO_LINES_ALL.UNIT_PRICE,
      AP.AP_INVOICE_DISTRIBUTIONS_ALL.UNIT_PRICE,
      sum(AP.AP_INVOICE_DISTRIBUTIONS_ALL.QUANTITY_INVOICED),
      sum(AP.AP_INVOICE_DISTRIBUTIONS_ALL.QUANTITY_VARIANCE),
      sum(nvl(AP.AP_INVOICE_DISTRIBUTIONS_ALL.BASE_QUANTITY_VARIANCE,0)),
      sum(AP.AP_INVOICE_DISTRIBUTIONS_ALL.INVOICE_PRICE_VARIANCE),
      sum(nvl(AP.AP_INVOICE_DISTRIBUTIONS_ALL.BASE_INVOICE_PRICE_VARIANCE,0))
    FROM
      PO.PO_LINES_ALL,
      PO.PO_HEADERS_ALL,
      PO.PO_VENDORS,
      PO.PO_VENDOR_SITES_ALL,
      PO.PO_LINE_LOCATIONS_ALL,
      AP.AP_INVOICE_DISTRIBUTIONS_ALL,
      PO.PO_DISTRIBUTIONS_ALL
    WHERE
      ( PO.PO_VENDORS.VENDOR_ID=PO.PO_HEADERS_ALL.VENDOR_ID  )
      AND  ( PO.PO_LINES_ALL.PO_LINE_ID=PO.PO_LINE_LOCATIONS_ALL.PO_LINE_ID  )
      AND  ( PO.PO_HEADERS_ALL.PO_HEADER_ID= PO.PO_LINES_ALL.PO_HEADER_ID  )
      AND  ( PO.PO_LINE_LOCATIONS_ALL.LINE_LOCATION_ID=PO.PO_DISTRIBUTIONS_ALL.LINE_LOCATION_ID  )
      AND  ( PO.PO_DISTRIBUTIONS_ALL.PO_DISTRIBUTION_ID=AP.AP_INVOICE_DISTRIBUTIONS_ALL.PO_DISTRIBUTION_ID  )
      AND  ( PO.PO_VENDOR_SITES_ALL.VENDOR_SITE_ID=PO.PO_HEADERS_ALL.VENDOR_SITE_ID  )
      AND  ( PO.PO_LINES_ALL.ORG_ID= 132  )  AND  ( PO.PO_HEADERS_ALL.ORG_ID = 132  )  AND  ( PO.PO_VENDOR_SITES_ALL.ORG_ID= 132  )  AND  ( PO.PO_LINE_LOCATIONS_ALL.ORG_ID= 132  )  AND  ( AP.AP_INVOICE_DISTRIBUTIONS_ALL.ORG_ID= 132  )  AND  ( PO.PO_DISTRIBUTIONS_ALL.ORG_ID= 132  )
      AND  
      (
       PO.PO_HEADERS_ALL.SEGMENT1  LIKE  'K%'
       AND
       AP.AP_INVOICE_DISTRIBUTIONS_ALL.ACCOUNTING_DATE  >=  '01-10-2009 00:00:00'
      )
    GROUP BY
      PO.PO_HEADERS_ALL.ATTRIBUTE1,
      PO.PO_HEADERS_ALL.ATTRIBUTE2,
      PO.PO_VENDORS.VENDOR_NAME,
      PO.PO_VENDOR_SITES_ALL.ZIP,
      PO.PO_HEADERS_ALL.SEGMENT1,
      PO.PO_LINES_ALL.LINE_NUM,
      PO.PO_LINES_ALL.ATTRIBUTE13,
      PO.PO_LINE_LOCATIONS_ALL.CANCEL_FLAG,
      PO.PO_LINE_LOCATIONS_ALL.CLOSED_CODE,
      PO.PO_LINES_ALL.ITEM_DESCRIPTION,
      PO.PO_LINES_ALL.UNIT_MEAS_LOOKUP_CODE,
      PO.PO_HEADERS_ALL.CURRENCY_CODE,
      nvl(PO.PO_HEADERS_ALL.RATE,1),
      nvl(AP.AP_INVOICE_DISTRIBUTIONS_ALL.EXCHANGE_RATE,1),
      PO.PO_LINES_ALL.UNIT_PRICE,
      AP.AP_INVOICE_DISTRIBUTIONS_ALL.UNIT_PRICE

  5. #4
    Sadik's Avatar
    Sadik is offline Administrator
    Join Date
    03 Aug 2008
    Location
    Kolkata, India
    Posts
    1,184
    Say Thanks
    7
    Thanked 83 Times in 54 Posts
    Documents
    4
    Uploads
    2

    Default Re: Query Performance Using PO and AP tables

    Hi

    Firstly, you don't need to use the Schema name in all your references to columns when you are accessing the APPS database as the APPS user. So you don't need to add the SCHEMA (PO, AP etc) prefix always.

    Secondly, you should use an alias after tablenames in your FROM statement. That is, for example, you should use, something like this:

    Code sql:
    SELECT   pha.segment1
      FROM   PO_HEADERS_ALL pha, PO_LINES_ALL pla
     WHERE   pla.po_header_id = pha.po_header_id

    Thirdly since you are already joining all tables on different conditions you don't need to check for ORG_ID's on all tables. Checking it on any one is sufficient and then you don't need to check on those tables which you joined with this one.

    Finally make sure your statement below, is being executed correctly.

    Code sql:
    AP.AP_INVOICE_DISTRIBUTIONS_ALL.ACCOUNTING_DATE  >=  '01-10-2009 00:00:00'

    Check it with like,
    Code sql:
    SELECT   *
      FROM   AP_INVOICE_DISTRIBUTIONS_ALL aia
     WHERE   aia.ACCOUNTING_DATE >= '01-10-2009 00:00:00'

    Just to make sure that the condition, your date format is correct.
    Learn Oracle with Oracle forum. Check out The Technology Blog

  6. #5
    grantie's Avatar
    grantie is offline Junior Member
    Join Date
    30 Nov 2009
    Posts
    6
    Say Thanks
    0
    Thanked 0 Times in 0 Posts
    Documents
    0
    Uploads
    0

    Default Re: Query Performance Using PO and AP tables

    Thanks Sadik. I will try the aliases as you suggest.

    I did try a simple query that just hit invoice distributions for the same date range and that took for ever as well. What should I be looking at? A different date format?

  7. #6
    Sadik's Avatar
    Sadik is offline Administrator
    Join Date
    03 Aug 2008
    Location
    Kolkata, India
    Posts
    1,184
    Say Thanks
    7
    Thanked 83 Times in 54 Posts
    Documents
    4
    Uploads
    2

    Default Re: Query Performance Using PO and AP tables

    can you post that simple date query?
    Learn Oracle with Oracle forum. Check out The Technology Blog

  8. #7
    mkandula's Avatar
    mkandula is offline Junior Member
    Join Date
    15 Jan 2010
    Posts
    3
    Say Thanks
    0
    Thanked 0 Times in 0 Posts
    Documents
    0
    Uploads
    0

    Default Re: Query Performance Using PO and AP tables

    Hello Grantie...

    Also for the date column if you are looking for just a date >= '01-10-2009' i guess u can better use this one...

    Code sql:
    SELECT   *
      FROM   AP_INVOICE_DISTRIBUTIONS_ALL aia
     WHERE   trunc(aia.ACCOUNTING_DATE) >= '10-JAN-2009';

    This query returned me results in less than 2 seconds. so do try this out too.

    Thanks
    Murali

  9. #8
    grantie's Avatar
    grantie is offline Junior Member
    Join Date
    30 Nov 2009
    Posts
    6
    Say Thanks
    0
    Thanked 0 Times in 0 Posts
    Documents
    0
    Uploads
    0

    Default Re: Query Performance Using PO and AP tables

    Hello Sadik and Murali.

    First when I removed the owner name, the table name wasn't recognised. I did manage to create aliases which at least makes the SQL more readable.

    Second, if I trunc the date, then performance is worse (I can see we have an index on accounting_date so using trunc would not make use of this index).

    But having made the following change I can < 10 second results for:

    Code sql:
    SELECT
      ID.ACCOUNTING_DATE
    FROM
      AP.AP_INVOICE_DISTRIBUTIONS_ALL  ID
    WHERE
      ID.ACCOUNTING_DATE  >=  '01-11-2009 00:00:00'

    So I am going to get my DBA to run an explain plan to see if that sheds any light.

  10. #9
    grantie's Avatar
    grantie is offline Junior Member
    Join Date
    30 Nov 2009
    Posts
    6
    Say Thanks
    0
    Thanked 0 Times in 0 Posts
    Documents
    0
    Uploads
    0

    Default Re: Query Performance Using PO and AP tables

    Also, on a related note, I am pulling out Qty_Received from PO Line Locations (amongst other things). I am then joining to PO Distributions and Invoice Distributions for other data. Now I have examples of where one PO Distribution can be invoiced via 2 (or more Invoice Distibrutions). So I had 3 PO Lines to start off with and 3 PO Distributions. But the PO was paid via 2 invoices which went into 4 distributions lines. In this case when I join across the tables my 3 rows are "inflated" into 3 rows and if I sum the Qty Received column, then I get the wrong number.

    Do you know of a clever way around this?

    Does it become easier over time :-((

  11. #10
    Sadik's Avatar
    Sadik is offline Administrator
    Join Date
    03 Aug 2008
    Location
    Kolkata, India
    Posts
    1,184
    Say Thanks
    7
    Thanked 83 Times in 54 Posts
    Documents
    4
    Uploads
    2

    Default Re: Query Performance Using PO and AP tables

    Try your query with TO_DATE

    Code sql:
    SELECT
      ID.ACCOUNTING_DATE
    FROM
      AP.AP_INVOICE_DISTRIBUTIONS_ALL  ID
    WHERE
      ID.ACCOUNTING_DATE  >=  to_date( '01-11-2009 00:00:00', 'MM/DD/RRRR HH24:MI:SS')

    Regarding your second points. try and first join PO lines with the invoice(s) and then from the invoice to the invoice distribution.

    And yes, with practice, these things won't bother you at all... btw i am actually a functional guy so bad at technical side of things. What i am saying to you is just from experience...
    Learn Oracle with Oracle forum. Check out The Technology Blog

Similar Threads

  1. Link between PO Tables and AP Tables
    By Monziac in forum Oracle Apps Technical
    Replies: 8
    Last Post: 01-13-2010, 01:44 PM
  2. SPfile Configuration for better performance
    By cbgreen in forum Server Administration and Options
    Replies: 1
    Last Post: 12-16-2009, 12:44 PM
  3. Slow Performance
    By mirza in forum Server Administration and Options
    Replies: 3
    Last Post: 12-08-2009, 02:24 PM
  4. performance issue in pl/sql program
    By r.uma in forum SQL PL/SQL
    Replies: 2
    Last Post: 11-13-2009, 07:25 AM
  5. Performance tweak on OC4J
    By mzainal in forum Oracle Fusion Middleware
    Replies: 0
    Last Post: 06-17-2009, 07:42 AM

Tags for this Thread