Help/Query Optimization

The below query runs in a second where the po_requisition_header _d in line 42 (5063 value) is hard coded. However, when it is joined to the outer query it takes minutes.
I have tried using hints. maybe I'm not using the right hint? Could does someone have any insight on how i can optimize this SQL query?
SELECT GCC.SEGMENT1
||'-'
||PORH.SEGMENT1
||'-'
||TO_CHAR(PORH.CREATION_DATE,'yy') CER_NUMBER,
PORH.AUTHORIZATION_STATUS STATUS,
REPLACE(SUBSTR(PORH.DESCRIPTION,DECODE(INSTR(PORH.DESCRIPTION,'~'),0,1,
(INSTR(PORH.DESCRIPTION,'~') + 1)),
LENGTH(PORH.DESCRIPTION)),'"') DESCRIPTION,
PORH.SEGMENT1 REQ_NUMBER,
PHA.SEGMENT1 PO_NUMBER,
MC.ATTRIBUTE3 MAJOR_CATEGORY,
GCC.SEGMENT1 DIVISION,
GCC.SEGMENT2 DISTRICT,
GCC.SEGMENT4 CCC,
PPX2.FULL_NAME PREPARER,
PPX.FULL_NAME REQUESTER,
PAA.ADDRESS_LINE1 ADDRESS_LINE1,
NVL(PAA.STATE,PAA.PROVINCE) STATE,
PAA.CITY CITY,
PLA.LOCATION_CODE BUILDING,
PORH.ATTRIBUTE1 PROJECT_NUMBER,
FV.DESCRIPTION PROJECT_DESCRIPTION,
PORH.ATTRIBUTE4 BREASON,
PORH.ATTRIBUTE9 BUSINESS_UNIT,
PORH.ATTRIBUTE3 ORIGINAL_CER,
TRUNC(PORH.CREATION_DATE) SUBMIT_DATE,
TRUNC(PORH.APPROVED_DATE) APPROVED_DATE,
(SELECT TO_CHAR(SUM((NVL(PORL2.UNIT_PRICE,0) * NVL(PORL2.QUANTITY,0))),
'FM999999990D00')
FROM PO_REQUISITION_LINES_ALL PORL2
WHERE PORL2.REQUISITION_HEADER_ID = PORH.REQUISITION_HEADER_ID) REQUISITION_AMOUNT,
(SELECT TO_CHAR(SUM(NVL(AIA.INVOICE_AMOUNT,0)),'FM999999990D00')
FROM AP_INVOICES_ALL AIA
WHERE AIA.INVOICE_ID in      
                    (SELECT AIA3.INVOICE_ID
FROM PO_REQUISITION_LINES_ALL PORL3,
AP_INVOICES_ALL AIA3,
AP_INVOICE_DISTRIBUTIONS_ALL AID3,
PO_DISTRIBUTIONS_ALL PDA3,
PO_REQ_DISTRIBUTIONS_ALL PRDA3
WHERE PORL3.REQUISITION_HEADER_ID = PORH.REQUISITION_HEADER_ID -- 5063 is the header id for rec 12168
AND PORL3.REQUISITION_LINE_ID = PRDA3.REQUISITION_LINE_ID
AND PRDA3.DISTRIBUTION_ID = PDA3.REQ_DISTRIBUTION_ID (+)
AND PDA3.PO_DISTRIBUTION_ID = AID3.PO_DISTRIBUTION_ID (+)
AND AID3.INVOICE_ID = AIA3.INVOICE_ID
                    group by AIA3.INVOICE_ID)) INVOICE_AMOUNT
FROM PO_REQUISITION_HEADERS_ALL PORH,
PO_REQUISITION_LINES_ALL PORL,
MTL_CATEGORIES MC,
PN_LOCATIONS_ALL PLA,
PN_ADDRESSES_ALL PAA,
PER_PEOPLE_X PPX,
PER_PEOPLE_X PPX2,
PO_HEADERS_ALL PHA,
PO_LINES_ALL PLA,
PO_LINE_LOCATIONS_ALL PLLA,
FND_FLEX_VALUES_VL FV,
FND_FLEX_VALUE_SETS FVS,
          PO_REQ_DISTRIBUTIONS_ALL PRDA,
          GL_CODE_COMBINATIONS GCC
WHERE PORH.REQUISITION_HEADER_ID = PORL.REQUISITION_HEADER_ID
AND PORL.LINE_NUM = (SELECT MIN(PORL2.LINE_NUM)
FROM PO.PO_REQUISITION_LINES_ALL PORL2
WHERE PORH.REQUISITION_HEADER_ID = PORL2.REQUISITION_HEADER_ID)
AND PORL.REQUISITION_LINE_ID = PRDA.REQUISITION_LINE_ID
AND PRDA.CODE_COMBINATION_ID = GCC.CODE_COMBINATION_ID
AND PORL.TO_PERSON_ID = PPX.PERSON_ID
AND PORH.PREPARER_ID = PPX2.PERSON_ID
AND MC.CATEGORY_ID = PORL.CATEGORY_ID
AND PORH.ATTRIBUTE5 = PLA.LOCATION_ID
AND PLA.ADDRESS_ID = PAA.ADDRESS_ID (+)
AND PORL.LINE_LOCATION_ID = PLLA.LINE_LOCATION_ID
AND PLA.PO_LINE_ID = PLLA.PO_LINE_ID
AND PHA.PO_HEADER_ID = PLA.PO_HEADER_ID
AND DECODE(PORH.ATTRIBUTE1,'N/A','XNULL',PORH.ATTRIBUTE1) = FV.FLEX_VALUE (+)
AND FV.FLEX_VALUE_SET_ID (+) = 1009209 --SR12372
AND FV.FLEX_VALUE_SET_ID = FVS.FLEX_VALUE_SET_ID (+)
AND PORH.AUTHORIZATION_STATUS IN ('APPROVED')
AND PORH.ATTRIBUTE2 IN ('Budgeted',
'Unbudgeted',
'Additional Amount')
AND PORH.ATTRIBUTE_CATEGORY = 'CAPEX'
          and porh.segment1 = '12168'
Thank you,
paul

Well...Here is the explain plan.
The problem line in this explain plain is ...
TABLE ACCESS FULL AP.AP_INVOICES_ALL     2 M     30 M 35641
Operation     Object Name     Rows     Bytes     Cost     Object Node     In/Out     PStart     PStop
SELECT STATEMENT Optimizer Mode=ALL_ROWS          1           66                     
SORT AGGREGATE          1      13                          
TABLE ACCESS BY INDEX ROWID     PO.PO_REQUISITION_LINES_ALL     3      39      4                     
INDEX RANGE SCAN     PO.PO_REQUISITION_LINES_U2     3           2                     
SORT AGGREGATE          1      11                          
FILTER                                        
TABLE ACCESS FULL     AP.AP_INVOICES_ALL     2 M     30 M     35641                     
FILTER                                        
SORT GROUP BY          1      42      1403                     
NESTED LOOPS          2      84      1402                     
NESTED LOOPS          2      72      1402                     
NESTED LOOPS          2      56      9                     
NESTED LOOPS          3      57      7                     
TABLE ACCESS BY INDEX ROWID     PO.PO_REQUISITION_LINES_ALL     3      27      4                     
INDEX RANGE SCAN     PO.PO_REQUISITION_LINES_U2     3           2                     
TABLE ACCESS BY INDEX ROWID     PO.PO_REQ_DISTRIBUTIONS_ALL     1      10      1                     
INDEX RANGE SCAN     PO.PO_REQ_DISTRIBUTIONS_N1     1           0                     
TABLE ACCESS BY INDEX ROWID     PO.PO_DISTRIBUTIONS_ALL     1      9      1                     
INDEX RANGE SCAN     PO.PO_DISTRIBUTIONS_N2     1           0                     
TABLE ACCESS BY INDEX ROWID     AP.AP_INVOICE_DISTRIBUTIONS_ALL     1      8      1393                     
INDEX RANGE SCAN     AP.AP_INVOICE_DISTRIBUTIONS_N7     2 K          0                     
INDEX UNIQUE SCAN     AP.AP_INVOICES_U1     1      6      0                     
NESTED LOOPS OUTER          1      459      64                     
NESTED LOOPS          1      416      63                     
NESTED LOOPS          1      397      62                     
NESTED LOOPS          1      379      61                     
NESTED LOOPS          1      321      58                     
NESTED LOOPS          1      311      57                     
NESTED LOOPS          1      303      57                     
NESTED LOOPS OUTER          1      295      56                     
HASH JOIN OUTER          1      289      56                     
NESTED LOOPS          1      254      10                     
NESTED LOOPS          1      241      9                     
NESTED LOOPS          1      233      8                     
NESTED LOOPS          1      225      7                     
NESTED LOOPS          1      201      6                     
TABLE ACCESS BY INDEX ROWID     PO.PO_REQUISITION_HEADERS_ALL     1      143      3                     
INDEX RANGE SCAN     PO.PO_REQUISITION_HEADERS_U2     1           2                     
TABLE ACCESS BY INDEX ROWID     HR.PER_ALL_PEOPLE_F     1      58      3                     
INDEX RANGE SCAN     HR.PER_PEOPLE_F_PK     3           0                     
TABLE ACCESS BY INDEX ROWID     PO.PO_REQUISITION_LINES_ALL     1      24      1                     
INDEX UNIQUE SCAN     PO.PO_REQUISITION_LINES_U2     1           0                     
SORT AGGREGATE          1      7                          
FIRST ROW          3      21      2                     
INDEX RANGE SCAN (MIN/MAX)     PO.PO_REQUISITION_LINES_U2     3      21      2                     
TABLE ACCESS BY INDEX ROWID     PO.PO_LINE_LOCATIONS_ALL     1      8      1                     
INDEX UNIQUE SCAN     PO.PO_LINE_LOCATIONS_U1     1           0                     
TABLE ACCESS BY INDEX ROWID     PO.PO_LINES_ALL     1      8      1                     
INDEX UNIQUE SCAN     PO.PO_LINES_U1     1           0                     
TABLE ACCESS BY INDEX ROWID     PO.PO_HEADERS_ALL     1      13      1                     
INDEX UNIQUE SCAN     PO.PO_HEADERS_U1     1           0                     
VIEW     APPS.FND_FLEX_VALUES_VL     55      1 K     45                     
NESTED LOOPS          55      2 K     45                     
TABLE ACCESS BY INDEX ROWID     APPLSYS.FND_FLEX_VALUES     41      820      4                     
INDEX RANGE SCAN     APPLSYS.FND_FLEX_VALUES_N3     41           1                     
TABLE ACCESS BY INDEX ROWID     APPLSYS.FND_FLEX_VALUES_TL     1      31      1                     
INDEX UNIQUE SCAN     APPLSYS.FND_FLEX_VALUES_TL_U1     1           0                     
INDEX UNIQUE SCAN     APPLSYS.FND_FLEX_VALUE_SETS_U1     1      6      0                     
TABLE ACCESS BY INDEX ROWID     INV.MTL_CATEGORIES_B     1      8      1                     
INDEX UNIQUE SCAN     INV.MTL_CATEGORIES_B_U1     1           0                     
INDEX UNIQUE SCAN     INV.MTL_CATEGORIES_TL_U1     1      8      0                     
TABLE ACCESS BY INDEX ROWID     PO.PO_REQ_DISTRIBUTIONS_ALL     1      10      1                     
INDEX RANGE SCAN     PO.PO_REQ_DISTRIBUTIONS_N1     1           0                     
TABLE ACCESS BY INDEX ROWID     HR.PER_ALL_PEOPLE_F     1      58      3                     
INDEX RANGE SCAN     HR.PER_PEOPLE_F_PK     3           0                     
TABLE ACCESS BY INDEX ROWID     GL.GL_CODE_COMBINATIONS     1      18      1                     
INDEX UNIQUE SCAN     GL.GL_CODE_COMBINATIONS_U1     1           0                     
TABLE ACCESS BY INDEX ROWID     PN.PN_LOCATIONS_ALL     1      19      1                     
INDEX RANGE SCAN     PN.PN_LOCATIONS_U1     1           0                     
TABLE ACCESS BY INDEX ROWID     PN.PN_ADDRESSES_ALL     1      43      1                     
INDEX UNIQUE SCAN     PN.PN_ADDRESSES_U1     1           0

Similar Messages

  • Need help to optimize query

    Hi
    I need help to optimize the below query.... I takes to long to execute.
    SELECT  vbak~waerk
                  vbapvbeln vbapposnr
                  vbapnetwr vbapbrgew vbap~erdat
            INTO CORRESPONDING FIELDS OF TABLE tmp_orders
            FROM vbak INNER JOIN vbap ON vbakvbeln = vbapvbeln
            WHERE vbap~matnr EQ t_mchb-matnr
            AND vbap~netwr   GT 0            
            AND vbap~brgew   GT 1                             
            AND vbak~auart     IN ('ZCAO', 'ZDDO').   
    Please help...
    Edited by: Alvaro Tejada Galindo on Mar 18, 2008 6:02 PM

    Hi,
    try this logic and see:
    data: begin of itab_for_vbak occurs 0,
          waerk type WAERK,
          vbeln type vbeln,
          end of itab_for_vbak,
          wa_for_vbak like itab_for_vbak.
    data: begin of itab_for_vbap occurs 0,
          vbeln like vbap-VBELN,
          posnr like vbap-POSNR,
          netwr like vbap-NETWR,
          brgew like vbap-brgew,
          erdat like ERDAT
          end of itab_for_vbap,
          wa_for_vbap like itab_for_vbap.
    SELECT
    waerk
    vbeln
    from
    vbak
    into table itab_for_vbak
    where
    vbak~auart IN ('ZCAO', 'ZDDO').
    select
    vbeln
    posnr
    netwr
    brgew
    erdat
    into table itab_for_vbap
    where
    vbap~matnr EQ t_mchb-matnr
    AND vbap~netwr GT 0
    AND vbap~brgew GT 1.
    loop at itab_for_vbak into wa_for_vbak.
    read table itab_for_vbap with key vbeln = wa_for_vbak-vbeln.
    if sy-subrc eq 0.
    tmp_orders-waerk = wa_for_vbak-waerk.
    tmp_orders-vbeln = wa_for_vbap-vbeln.
    tmp_orders-posnr = wa_for_vbap-posnr.
    tmp_orders-brgew = wa_for_vbap-brgew.
    tmp_orders-erdat = wa_for_vbap-erdat.
    append tmp_orders.
    endif.
    endloop.
    Please let me know how it has improved your performance or still if you have issues on this.
    Thanks,
    Vishnu.

  • Reg Query Optimization - doubts..

    Hi Experts,
    This is related to Blog by Mr Prakash Darji regarding "Query Optimization" posted on Jan 26 2006.In this to optimize query Generation of Report is suggested.
    I tried this, but I am not sure I am analyzing this correctly.
    I collected Stats data before and after Generation of Report.But how to be sure that this is helping me? Did any one has tried this?
    What to look for in Stats Data - duration?
    But duration would not be absolute parameter as there is factor of "Wait Time, User", so duration may depend on this.
    Please help me in this.
    Thanks
    Gaurav
    Message was edited by: Gaurav

    Any ideas Experts?

  • SQL Server 2008R2 SP2 Query optimizer memory leak ?

    It looks like we are facing a SQL Server 2008R2 queery optimizer memory leak.
    We have below version of SQL Server
    Microsoft SQL Server 2008 R2 (SP2) - 10.50.4000.0 (X64)
     Jun 28 2012 08:36:30
     Copyright (c) Microsoft Corporation
     Standard Edition (64-bit) on Windows NT 6.1 <X64> (Build 7601: Service Pack 1)
    The instance is set MAximum memory tro 20 GB.
    After executing a huge query (2277 kB generated by IBM SPSS Clementine) with tons of CASE and a lot of AND/OR statements in the WHERE and CASE statements and muliple subqueries the server stops responding on Out of memory in the internal pool
    and the query optimizer has allocated all the memory.
    From Management Data Warehouse we can find that the query was executed at
    7.11.2014 22:40:57
    Then at 1:22:48 we recieve FAIL_PACE_ALLOCATION 1
    2014-11-08 01:22:48.70 spid75       Failed allocate pages: FAIL_PAGE_ALLOCATION 1
    And then tons of below errors
    2014-11-08 01:24:02.22 spid87      There is insufficient system memory in resource pool 'internal' to run this query.
    2014-11-08 01:24:02.22 Server      Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:02.22 Server      Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:02.30 Server      Error: 17312, Severity: 16, State: 1.
    2014-11-08 01:24:02.30 Server      SQL Server is terminating a system or background task Fulltext Host Controller Timer Task due to errors in starting up the task (setup state 1).
    2014-11-08 01:24:02.22 spid74      Error: 701, Severity: 17, State: 123.
    2014-11-08 01:24:02.22 spid74      There is insufficient system memory in resource pool 'internal' to run this query.
    2014-11-08 01:24:13.22 Server      Error: 17312, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:13.22 spid87      Error: 701, Severity: 17, State: 123.
    2014-11-08 01:24:13.22 spid87      There is insufficient system memory in resource pool 'internal' to run this query.
    2014-11-08 01:24:13.22 spid63      Error: 701, Severity: 17, State: 130.
    2014-11-08 01:24:13.22 spid63      There is insufficient system memory in resource pool 'internal' to run this query.
    2014-11-08 01:24:13.22 spid57      Error: 701, Severity: 17, State: 123.
    2014-11-08 01:24:13.22 spid57      There is insufficient system memory in resource pool 'internal' to run this query.
    2014-11-08 01:24:13.22 Server      Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:18.26 Server      Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:24.43 spid81      Error: 701, Severity: 17, State: 123.
    2014-11-08 01:24:24.43 spid81      There is insufficient system memory in resource pool 'internal' to run this query.
    2014-11-08 01:24:18.25 Server      Error: 18052, Severity: -1, State: 0. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:18.25 Server      BRKR TASK: Operating system error Exception 0x1 encountered.
    2014-11-08 01:24:30.11 Server      Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:30.11 Server      Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:35.18 spid57      Error: 701, Severity: 17, State: 131.
    2014-11-08 01:24:35.18 spid57      There is insufficient system memory in resource pool 'internal' to run this query.
    2014-11-08 01:24:35.18 spid71      Error: 701, Severity: 17, State: 193.
    2014-11-08 01:24:35.18 spid71      There is insufficient system memory in resource pool 'internal' to run this query.
    2014-11-08 01:24:35.18 Server      Error: 17312, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:35.41 Server      Error: 17312, Severity: 16, State: 1.
    2014-11-08 01:24:35.41 Server      SQL Server is terminating a system or background task SSB Task due to errors in starting up the task (setup state 1).
    2014-11-08 01:24:35.71 Server      Error: 17053, Severity: 16, State: 1.
    2014-11-08 01:24:35.71 Server      BRKR TASK: Operating system error Exception 0x1 encountered.
    2014-11-08 01:24:35.71 spid73      Error: 701, Severity: 17, State: 123.
    2014-11-08 01:24:35.71 spid73      There is insufficient system memory in resource pool 'internal' to run this query.
    2014-11-08 01:24:46.30 Server      Error: 17312, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:51.31 Server      Error: 17053, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:51.31 Server      Error: 17300, Severity: 16, State: 1. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    2014-11-08 01:24:51.31 Logon       Error: 18052, Severity: -1, State: 0. (Params:). The error is printed in terse mode because there was error during formatting. Tracing, ETW, notifications etc are skipped.
    Last error message is half an hour after the inital Out of memory at 2014-11-08 01:52:54.03. Then the Instance is completely shut down
    From the memory information in the error log we can see that all the memory is consumed by the QUERY_OPTIMIZER
    Buffer Pool                                   Value
    Committed                                   2621440
    Target                                      2621440
    Database                                     130726
    Dirty                                          3682
    In IO                                            
    0
    Latched                                          
    1
    Free                                           
    346
    Stolen                                      2490368
    Reserved                                          0
    Visible                                     2621440
    Stolen Potential                                  0
    Limiting Factor                                  17
    Last OOM Factor                                   0
    Last OS Error                                     0
    Page Life Expectancy                             28
    2014-11-08 01:22:48.90 spid75     
    Process/System Counts                         Value
    Available Physical Memory                29361627136
    Available Virtual Memory                 8691842715648
    Available Paging File                    51593969664
    Working Set                               628932608
    Percent of Committed Memory in WS               100
    Page Faults                                48955000
    System physical memory high                       1
    System physical memory low                        0
    Process physical memory low                       1
    Process virtual memory low                        0
    MEMORYCLERK_SQLOPTIMIZER (node 1)                KB
    VM Reserved                                       0
    VM Committed                                      0
    Locked Pages Allocated                            0
    SM Reserved                                       0
    SM Committed                                      0
    SinglePage Allocator                       19419712
    MultiPage Allocator                             128
    Memory Manager                                   KB
    VM Reserved                               100960236
    VM Committed                                 277664
    Locked Pages Allocated                     21483904
    Reserved Memory                                1024
    Reserved Memory In Use                            0
    On the other side MDW reports that the MEMORYCLERK_SQLOPTIMIZER increases since the execution of the query up to the point of OUTOF MEMORY, but the Average value is 54.7 MB during that period as can be seen on attached graph.
    We have encountered this issue already two times (every time the critical query is executed).

    Hi,
    This does seems to me kind of memory Leak and actually it is from SQL Optimizer which leaked memory from buffer pool so much that it did not had any memory to be allocated for new page.
    MEMORYCLERK_SQLOPTIMIZER (node 1)                KB
    VM Reserved                                       0
    VM Committed                                      0
    Locked Pages Allocated                            0
    SM Reserved                                       0
    SM Committed                                      0
    SinglePage Allocator                       19419712
    MultiPage Allocator                             128
    Can you post complete DBCC MEMORYSTATUS output which was generated in errorlog. Is this the only message in errorlog or there are some more messages before and after it.
    select (SUM(single_pages_kb)*1024)/8192 as total_stolen_pages, type
    from sys.dm_os_memory_clerks
    group by typeorder by total_stolen_pages desc
    and
    select sum(pages_allocated_count * page_size_in_bytes)/1024,type from sys.dm_os_memory_objects
    group by type
    If you can post the output of above two queries with dbcc memorystaus output on some shared drive and share location with us here. I would try to find out what is leaking memory.
    You can very well apply SQL Server 2008 r2 SP3 and see if this issue subsides but I am not sure whether this is fixed or actually it is a bug.
    Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
    My Technet Wiki Article
    MVP

  • Any software for Query Optimization?

    Hi,
    Is there any software to be used for query Optimization
    Please help me

    3rd party tools suck (if they did not Oracle would incorporate them in its optimizer long ago). The best tools are:
    1. Gather table and index statistics
    2. Use CBO (FIRST_ROWS, ALL_ROWS)
    3. SQL*Plus AUTOTRACE
    4. EXPLAIN PLAN
    5. SET SQL_TRACE = TRUE + TKPROF
    6. Statspack
    7. Enterprise manager (new Ora10g, did not try it)
    All from Oracle...

  • The query processor ran out of stack space during query optimization. Please simplify the query

    Can you suggest me that what should i do in this case.
    Actually i am having one table that is a MasterTable.I am referring this table in more than 300 tables that means i am having foreign key of this primary key in 300+ tables.
    due to this i am getting following error during deleting any row,
    doesn't matter that data is existing in reference table or not.
    Error that i am getting is 
    "The query processor ran out of stack space during query optimization. Please simplify the query"
    Can you suggest me that what should i do to avoid this error,because i am unable to delete this entry.
    Apart from it,i am getting performance problem too,so is it due to such huge FK on it.
    Please suggest me on following points
    1. Is it worst way to handle it,if yes then please suggest me solution for it.
    2. If it is a correct way then what should i do if getting error during deleting any record.
    3. Is it right to create Foreign key on each table where i am saving data of this master. if no then how to manage integrity.
    4. What people do in huge database when they wants to create foreign key for any primary key.
    5. Can you suggest me that how DBA's are handling this in big database,where they are having huge no. of tables.

    The most common reason of getting such error is having more than 253 foreign key constraints on a table. 
    The max limit is documented here:
    http://msdn.microsoft.com/en-us/library/ms143432(SQL.90).aspx 
    Although a table can contain an unlimited number of FOREIGN KEY constraints, the recommended maximum is 253. Depending on the hardware configuration hosting SQL Server, specifying additional foreign key constraints may be expensive for the query
    optimizer to process. If you are on 32 bit, then you might want to move to 64 bit to get little bigger stack space but eventually having 300 FK is not something which would work in long run.
    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    This posting is provided "AS IS" with no warranties, and confers no rights.
    My Blog |
    Team Blog | @Twitter
    Author: SQL Server 2012 AlwaysOn -
    Paperback, Kindle

  • HFR - Data Query Optimization Settings

    hi
    In HFR, in a grid there are Data Query Optimization Settings, can you please help me on the settings property.
    Our report fetches data using lot of attributes. When we don't use MDX setting, it fetches very fast, but the alias doesn't come.
    However, when we use MDX setting, the alias comes, but the report takes lot of time to run(approx 1 min / row of data fetched)
    Can you please guide on the same.
    Thanks

    pm wrote:
    Hi ,
    I am working on below query optimization/Tuning.
    SELECT
    c_date,
    c1,
    c2,
    c3,
    c4,
    c5,
    c6
    FROM tab1
    WHERE
    ROWNUM <= &param
    AND ( c_date BETWEEN &date1 AND &date2 )
    AND c3 in (
    select c3
    from tab2
    where xxx='abc')
    ORDER BY c1, c_date;
    Note : &param,&date1 ,&date2 are parameters runtime getting from UI code .
    tab1 having huge data around 10lacs to crores. and it has range partition on c_date column and subpartiotion on c1 column.
    To get best throughput in less time, what i need to do ?
    Please do let me know steps to tune/optimize the sql query.Also which hint we can use on sql query to better results.
    Thanks in advanced.
    PMBefore you start worrying about performance tuning you should worry about the query being incorrect.
             WHERE
                 ROWNUM <= &param
                 AND   ( c_date BETWEEN &date1 AND &date2 )
                 AND c3 in (
                                             select c3
                                             from tab2
                                             where xxx='abc')
             ORDER BY c1, c_date;Presumably you want to limit the number of rows with the ROWNUM predicate AFTER the ORDER BY clause is applied.
    Please read this and learn how queries are actually processed, I can almost guarantee you this query is not doing what you think it is doing at present.
    http://www.oracle.com/technetwork/issue-archive/2006/06-sep/o56asktom-086197.html
    Cheers,

  • Need Query Optimization Info

    Hi Everyone:
    I have a user on my site who's trying to find information on database query optimization. She's willing to pay $3 to someone who will give her some very basic information. I figured those of you who read this forum would have something handy you could just provide to her. It's not the information she's paying for, but the service of someone retrieving it for her. Would someone take a look? You can find her request here:
    http://www.yepic.com/index.php?module=ContReq&hdnRequestID=8
    The one problem is you have to register on the site before you can post your response. You just need to give create a username, email and password, though. It's very easy. I'd appreciate someone helping one of my users out.

    . . . she's trying to avoid the
    search taxSearch tax... never heard it put that way. I guess you are trying to avoid the "search engine" tax by advertising your site here? Maybe some one will help you out by answering the request from Corey for Search Engine Optimization.

  • Oracle 11g on Linux : Query Optimization issue

    Hi guru,
    I am facing one query optimization related problem in group by query
    Table (10 million Records)
    Product(ProductId number,ProductName varchar(100),CategoryId VARCHAR2(38),SubCategoryId VARCHAR2(38))
    Index
    create index idxCategory on Product (CategoryId,SubCategoryId)
    Query1:To find product count for all CategoryId and SubCategoryId
    select CategoryId,SubCategoryId,count(*) from Product group by CategoryId,SubCategoryId
    Above query is not using index idxCategory and doing table scan which is very costly.
    When I fire Query2: select count(*) from Product group by CategoryId,SubCategoryId
    then it is properly using index idxCategory and very fast.
    Even I specified hint in Query1 but it is not using hint.
    Can anybody suggest why oracle is not using index in Query1 and what should I do so that Query1 will use Index.
    Thanks in advance.

    user644199 wrote:
    I am facing one query optimization related problem in group by query
    Query1:To find product count for all CategoryId and SubCategoryId
    select CategoryId,SubCategoryId,count(*) from Product group by CategoryId,SubCategoryId
    Above query is not using index idxCategory and doing table scan which is very costly.
    When I fire Query2: select count(*) from Product group by CategoryId,SubCategoryId
    then it is properly using index idxCategory and very fast.
    Even I specified hint in Query1 but it is not using hint.
    Can anybody suggest why oracle is not using index in Query1 and what should I do so that Query1 will use Index.The most obvious reason that the table needs to be visited would be that the columns "CategoryId" / "SubCategoryId" can be NULL but then this should apply to both queries. You could try the following to check the NULL issue:
    select CategoryId,SubCategoryId,count(*) from Product where CategoryId is not null and SubCategoryId is not null group by CategoryId,SubCategoryId
    Does this query use the index?
    Can you show us the hint you've used to force the index usage and the EXPLAIN PLAN output of the two queries including the "Predicate Information" section? Use DBMS_XPLAN.DISPLAY to get a proper output, and use the \ tag before and after when posting here to format it using fixed font. Use the "Quote" button in the message editor to see how I used the \ tag here.
    Are above queries representing the actual queries used or did you omit some predicates etc. for simplicity?
    By the way, VARCHAR2(38) and ...ID as name, are these columns storing number values?
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • What is query optimization and how to do it.

    Hi
    What is query optimization?
    Any link can any one provide me so that i can read and learn the techniques.
    Thanks
    Elias Maliackal

    THis is an excellent place to start: When your query takes too long ...

  • OBIEE 11.1.1.7-Ago Function Error-[nQSError: 46008] Internal error: File server\Query\Optimizer\SmartScheduler\PhysicalRequestGenerator\Src\SQOSPMarkMultiTargetSupport.cpp

    Hi All,
    I was performing the steps mentioned in Oracle Tutorial"http://www.oracle.com/webfolder/technetwork/tutorials/obe/fmw/bi/bi11115/biadmin11g_02/biadmin11g.htm#t10"-BI RPD creation.
    After Using the AGO function data in the Time series metric(Month Ago Revenue) was null always. I updated the DB features in RPD physical layers by selecting support for time series functions.
    After that report started to fail with below error. Please let me know if its a bug and any option to fix it.
    Thanks,
    Sreekanth
    Error
    View Display Error
    Odbc driver returned an error (SQLExecDirectW). 
      Error Details
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P 
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 46008] Internal error: File server\Query\Optimizer\SmartScheduler\PhysicalRequestGenerator\Src\SQOSPMarkMultiTargetSupport.cpp, line 1680. (HY000) 
    SQL Issued: SELECT 0 s_0, "Sample Sales"."Time"."Year-L1" s_1, "Sample Sales"."Revenue"."Ago-Year Revenue" s_2, "Sample Sales"."Revenue"."Revenue" s_3 FROM "Sample Sales" FETCH FIRST 65001 ROWS ONLY
      Refresh

    I know that there is no relation between "SampleApp Lite"."D3 Orders (Facts Attributes)"."Order Date", "SampleApp Lite"."D0 Time"."Calendar Date", it's also the same thing in my own RPD.
    But as it's working with the 11.1.1.6.2 BP1 version I don't understand why it's not working with 11.1.1.6.9.
    Implicit fact column is not set on my repository, but I don't have any request with only dimensional column, so if my understanding is correct I don't need to use it. Also, the problem appears during the check of the repository not in answers.
    thanks anyway

  • How to do query Optimization ,plz share any documents with real examples

    Hi All,
    could any one please provide me some informations, how can i do query optimization in oracle using Third party tool sql developer .
    i am working oracle 10g version,please share with me if any documents or ppt like that.
    Thanks
    Krupa

    879534 wrote:
    Hi All,
    could any one please provide me some informations, how can i do query optimization in oracle using Third party tool sql developer .SQL Developer is Oracle's development tool, not a third party tool.
    Questions about using SQL Developer should go in the SQL Developer forum:
    SQL Developer
    I'll move the question there for you.

  • Regarding Query Optimization

    Hi Gurus,
    I am preparing for an interview. I need to know about Query Optimization, explain plan, Cost analysis.
    Can anyone please give me some reference link or site where i can get step by step details for the above..
    It would be really helpfull.
    Thanks in advance..
    Ameya.

    RTFM [url http://oraclesvca2.oracle.com/docs/cd/B10501_01/server.920/a96533/toc.htm]Performance Tuning Guide and Reference

  • Aggregate Query Optimization (with indexes) for trivial queries

    Table myTable, which is quite large, has an index on the month column.
    "select max(month) from myTable" uses this index and returns quickly.
    "select max(month) from myTable where 1 = 1" does not use this index, falls through to a full table scan, and takes a very long time.
    Can this possibly be a genuine omission in the query optimizer, or is there some setting or another to convince it to perform the latter query more sanely?

    Oracle 11.2.0.1
    SQL> select table_name, num_rows from dba_tables where table_name = 'DWH_ADDRESS_MASTER';
    TABLE_NAME                                 NUM_ROWS
    DWH_ADDRESS_MASTER                        295729948
    SQL> explain plan for select max(last_update_date) from DWH.DWH_ADDRESS_MASTER;
    | Id  | Operation                  | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT           |                        |     1 |     8 |     4   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE            |                        |     1 |     8 |            |          |
    |   2 |   INDEX FULL SCAN (MIN/MAX)| DWH_ADDRESS_MASTER_N1  |     1 |     8 |     4   (0)| 00:00:01 |
    SQL> explain plan for select max(last_update_date) from DWH.DWH_ADDRESS_MASTER where 1 = 1;
    | Id  | Operation                   | Name                   | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT            |                        |     1 |     8 |     4   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE             |                        |     1 |     8 |            |          |
    |   2 |   FIRST ROW                 |                        |     1 |     8 |     4   (0)| 00:00:01 |
    |   3 |    INDEX FULL SCAN (MIN/MAX)| DWH_ADDRESS_MASTER_N1  |     1 |     8 |     4   (0)| 00:00:01 |
    ------------------------------------------------------------------------------------------------------

  • Autonomic Query Optimizer

    Hi All,
    I'm doing some bit of study on that portion of Query Optimizer in Oracle9i that is autonomic (I mean it is dynamic and a self learning one).Can anyone give me some pointers to this topic(In fact I doubt whether something like this at all exists, or is still a topic of research); I need some more info on this topic.Some papers or articles may be handy.
    Greetings,
    Kaustav Ghoshal

    I think u mean CBO (Cost Based Optimizer). If your database is running in "choose" mode so yes, CBO will automaticly optimize your query.
    Check the doc here : http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96533/part1.htm
    Fred

Maybe you are looking for

  • Cisco SIP Phone 9971 won't register on CME 8.6 or 8.5 Please HELP

    Please help me , I have problem with registering Cisco SIP phone 9971 with CME 8.6 on ISR 2901. I configured CME for SIP clients, then I add configuration for 9971 phone and create profiles.  Phone downloaded SEP...xml file from CME,after that phone

  • Why do I have 2 icons for WD Mybook Edition II?

    I have two icons on my desktop title line (don't know if this is correct name for the top horizontal bar) for my WD Mybook Edition II backup.  I had a problem with the WD a few months ago and I somehow got it fixed but am unsure how that happened.  N

  • Can a thief take out the sim card and use phone like new?

    I recently left my phone in a public bathroom and when I went back it was gone. So I believe someone has taken it and has turned it off. I am using Find my iPhone but the person has not turned my phone on in 3 days. I'd like to know, what could he/sh

  • Capture offsets broken?

    Is anyone having the same problems I'm having adjusting RS-422 timecode offsets on capture? They just won't stick... We do a regular show that's offlined on Avid, and finished via Automatic Duck in FCP and Color. As you'd expect from Avid's deck-spec

  • Using the text message facility on PC Suite.

    I have loaded the PC suite onto my pc and have managed to sync dates , contacts, photos etc. Evertime I try to send a text message I get the following On right clicking on message a pop up window informs me that phone connection is lost. the text mes