Query runs for ever - suggestions - ideas - tips

Hello all,
I have the following situation:
1) Database 1: XE 10g Release 10.2.0.1.0 - Production
2) Database 2: 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
3) Dblink from Database 1 pointing to Database 2
4) Synonyms created withing Database 1, pointing to Database 2 packages and tables:
- "mytable1" exists in Database 2 therefore a synonym "mytable1" is created in Database 1
- "mytable2" exists in Database 2 therefore a synonym "mytable2" is created in Database 1
- "mypackage" exists in Database 2 therefore a synonym "mypackage" is created in Database 1
5) Of course select and execute rights are granted
6) Query:
SELECT field1
FROM myshcema.mytable1
WHERE field2 = myshcema.mypackage.myfunction ('PARAMVALUE'))
AND EXISTS (SELECT 1 FROM myshcema.mytable2 WHERE field_in_tab2 = field_in_tab1)
7) Problem.This query runs for ever
8) Explain plan
OPERATION - OBJECT_NAME - OPTIONS - COST
SELECT STATEMENT - - - 17
-> FILTER - - -
-> -> FILTER - - - 3
-> -> -> REMOTE - mytable1 - -
-> -> REMOTE - mytable2 - - 1
9) Now I get the value returned by the function and re-execute the previous query:
- select myshcema.mypackage.myfunction ('PARAMVALUE')) from dual;
- return value is *89787621*
- re-executing the query:
SELECT field1
FROM myshcema.mytable1
WHERE field2 = *89787621*
AND EXISTS (SELECT 1 FROM myshcema.mytable2 WHERE field_in_tab2 = field_in_tab1)
10) Explain plan
OPERATION - OBJECT_NAME - OPTIONS - COST
SELECT STATEMENT - - REMOTE - 3
-> NESTED LOOPS - - SEMI - 3
-> -> INDEX - MY_UK_NAME - RANGE SCAN - 3
-> -> INDEX - MY_2ND_UK - UNIQUE SCAN - 0
And the results are instantaneous
Now my question: Can somebody direct me on whether a hint or something else will correct this situation? Due to restrictions that I cannot currently explain here, I am not able to change the code to first get the value and then execute the query.
Thanks for helping
G
Edited by: G on May 17, 2011 9:07 AM
Edited by: G on May 17, 2011 9:10 AM

I would think the driving site hint woud be the frist thing I tried. If for some reason Oracle does not seem to be able to use the hint or if hints are heavily frowned on at your site then here is another approach to the problem.
Code the query into a view and define the view on the remote database then issues a local query against the remote view.
HTH -- Mark D Powell --

Similar Messages

  • Query runs for ever

    I have three summary tables which are yearly,monthly and daily. The yearly table has year and some aggreagted facts. The monthly table has year,month and some aggregated facts while day table has year,month and day and some aggregated facts.
    I ran a Query on yearly table and monthly table with a join on year for these fields
    Year(year from yearly table)
    month and some aggregated facts (monthly table). This query runs forever. But if I pull all these fields from monthly table it runs fast. Can I join on year to pull the data. I dont have any keys in these tables.

    Query from different tables:
    SELECT
    PMAC.ACT_ALL_SUM_YEAR.DEPT_AIRPORT,
    PMAC.ACT_ALL_SUM_YEAR.ARR_AIRPORT,
    (PMAC.ACT_ALL_SUM_YEAR.DATE_YEAR),
    PMAC.ACT_ALL_SUM_MONTH.AVG_AIRB,
    (PMAC.ACT_ALL_SUM_MONTH.DATE_MONTH)
    FROM
    PMAC.ACT_ALL_SUM_YEAR,
    PMAC.ACT_ALL_SUM_MONTH,
    PMAC.ACT_ALL_SUM_DAY
    WHERE
    ( PMAC.ACT_ALL_SUM_YEAR.DATE_YEAR=PMAC.ACT_ALL_SUM_DAY.DATE_YEAR )
    AND ( PMAC.ACT_ALL_SUM_DAY.DATE_YEAR=PMAC.ACT_ALL_SUM_MONTH.DATE_YEAR )
    AND
    PMAC.ACT_ALL_SUM_YEAR.DEPT_AIRPORT = 'ATL'
    AND
    PMAC.ACT_ALL_SUM_YEAR.ARR_AIRPORT = 'JFK'
    AND
    (PMAC.ACT_ALL_SUM_YEAR.DATE_YEAR) In ( '2001','2002','2003' )
    )Query to pull data from single table:
    SELECT
      PMAC.ACT_ALL_SUM_MONTH.AVG_AIRB,
      (PMAC.ACT_ALL_SUM_MONTH.DATE_MONTH),
      PMAC.ACT_ALL_SUM_MONTH.ARR_AIRPORT,
      PMAC.ACT_ALL_SUM_MONTH.DEPT_AIRPORT,
      (PMAC.ACT_ALL_SUM_MONTH.DATE_YEAR)
    FROM
      PMAC.ACT_ALL_SUM_MONTH
    WHERE
       PMAC.ACT_ALL_SUM_MONTH.DEPT_AIRPORT  =  'ATL'
       AND
       PMAC.ACT_ALL_SUM_MONTH.ARR_AIRPORT  =  'JFK'
       AND
       (PMAC.ACT_ALL_SUM_MONTH.DATE_YEAR)  In  ( '2001','2002','2003'  )
      )These are two queries which I was working on. The first query takes too much time to run and it runs fast on the second query. How can I optimise the first query. Can we include any keys in these tables to make the query faster.
    Edited by: user9518444 on Dec 3, 2008 7:34 AM
    Edited by: user9518444 on Dec 3, 2008 7:38 AM

  • Sql is running for ever

    We have one report which will process every night which is running good from couple of years. Today that report is running for ever. I extrated sql from that report and if I run that sql by giving * after select, it is giving result with in one minute. If I run the sql by selecting column names, it is running for ever. Our daily report will run by selecting few columns from three tables. We are using choose based optimizer.
    But when I run the same query by selecting the columns, with yesterday, I will get the output with in one minute. If I run the same query for today's date, getting that problem. But we had almost more than 10 thousand transactions over night. Not sure whether I need to run compute statistics on those tables which can fix the problem.
    Pls advice how to fix this. Our db is 9i.
    Thanks in advance.
    Hari Babu
    Edited by: user6367891 on Oct 8, 2009 12:55 PM

    Pl also see HOW TO: Post a SQL statement tuning request - template posting
    The information you have posted so far is insufficient to make any kind of diagnosis.
    HTH
    Srini

  • Dbms_scheduler job neither succeeds nor errors its just keep running for ever

    Hi All,
    I am trying to run a shell script from plsql using the dbms_scheduler, job is getting created and it keeps running for ever without success or error.
    Can some please help me where I am doing the mistake.
    Thanks
    DB Version:
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    PL/SQL Release 10.2.0.5.0 - Production
    Plsql Script:
    BEGIN
       DBMS_SCHEDULER.create_job (
          job_name              => 'SFTP_PAYMENTECH_BATCHID1',
          job_type              => 'EXECUTABLE',
          job_action            => '/app07/ebdev/ebdevappl/xxtpc/bin/test.sh',
          number_of_arguments   => 1,
          enabled               => FALSE,
          auto_drop             => TRUE,
          comments              => 'SFTP Batch File to Paymentech');
       DBMS_OUTPUT.put_line (
          'Job Created Successfully:' || 'SFTP PAYMENTECH BATCHID');
       fnd_file.put_line (
          fnd_file.output,
          'Job Created Successfully:' || 'SFTP PAYMENTECH BATCHID');
       COMMIT;
       DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
          job_name            => 'SFTP_PAYMENTECH_BATCHID1',
          argument_position   => 1,
          argument_value      => '66667'                        /*v_printer_name*/
       DBMS_SCHEDULER.enable (name => 'SFTP_PAYMENTECH_BATCHID1');
    EXCEPTION
       WHEN OTHERS
       THEN
          fnd_file.put_line (fnd_file.output,
                             'Error while creating the Job:' || SQLERRM);
          DBMS_OUTPUT.put_line ('Error while creating the Job:' || SQLERRM);
    END;
    Shell Script which I am calling:
    #!/usr/bin/ksh
    FILENAME=$1
    PMTHOST=198.xx.xx.xx
    PMTUSER=xxxxx
    PMTPW=xxxxx
    a='apps'
    b='xxxxxx'
    c='EBDEV'
    INST=`echo $TWO_TASK | sed 's/_BALANCE//'`
    echo INSTANCE: $INST
    echo
    File_Path=$XXTPC_TOP/iby/out
    echo File Name: $FILENAME
    echo $PMTHOST
    echo $PMTUSER
    echo
    echo Date: `date`
    echo
    echo File System User: `whoami`
    echo
    echo Instance: $TWO_TASK
    echo
    echo File_Path: $File_Path
    echo
    echo PMT SFTP
    # Fetch file using MBATCHID as File Name
    cd $File_Path
    echo
    echo -----------------------------------------------
    echo
    echo Current File          :$FILENAME
    l_date_time=`date +%Y%m%d%H%M%S`
    echo SFTP Remittance File
    # sftp $PMTUSER@$PMTHOST << EOF
    lftp -u $PMTUSER,$PMTPW sftp://$PMTHOST << EOF
    lcd $File_Path
    cd test/945299
    put $FILENAME
    exit
    EOF
    #`sqlplus -s apps/tpcdev2013@EBDEV @try.sql $FILENAME`

    Have you tried running the script manually to confirm it isnt just hanging on input for the lftp ?
    You could add a -o <file> to the lftp command line which would output debug info into <file> so you could see.
    Creation of the job looks fine so as GregV said, what output do you have in ALL_SCHEDULER_RUNNING_JOBS and any ADDITIONAL_INFO in the ALL_SCHEDULER_JOB_RUN_DETAILS or in $ORACLE_HOME/scheduler/log that might indicate what the problem is ?
    If this answer was helpful, please mark as helpful answer. 

  • Query running for a very long time

    Hi I have a sales Query which is running for a very long time,
    It is built on a multiprovider. The multiprovider gets feed from cube and DSO.
    It is taking very long time to run.
    I need to do some performance tuning can you please suggest.

    Hi Ravi,
    First maitain BW statistics for that query and after that go to se11 and give table RSDDSTAT. just check how many records selected in data base and how many records transferred.
    according to this statistics create aggregates by giving propose aggregates by using statistics tables. after running a query check in RSRT whether the data is coming from aggregates or not.
    do not exclude any selections try to include in query restrictions.
    try to create secondary indexes.
    let us know the result.

  • Query running for long post upgrade to Oracle 11g from 10g

    The below query is running for a very long time post upgrade of database from 10g to 11g.
    SELECT default_supplier
      FROM (SELECT pv.vendor_name || '-'
                   || pvsa.vendor_site_code default_supplier
              FROM mrp_item_sourcing_levels_v mislv,
                   mfg_lookups ml1,
                   mfg_lookups ml2,
                   mfg_lookups ml3,
                   mtl_system_items_b msib,
                   po_vendors pv,
                   po_vendor_sites_all pvsa
             WHERE msib.segment1 = :b1
               AND msib.organization_id = :b2
               AND mislv.inventory_item_id = msib.inventory_item_id
               AND mislv.organization_id = msib.organization_id
               AND ml1.lookup_type = 'MRP_SOURCING_RULE_TYPE'
               AND ml1.lookup_code = mislv.sourcing_rule_type
               AND ml2.lookup_type = 'MRP_ASSIGNMENT_TYPE'
               AND ml2.lookup_code = mislv.assignment_type
               AND pv.vendor_id = mislv.vendor_id
               AND pvsa.vendor_site_id = mislv.vendor_site_id
               AND pvsa.vendor_id = mislv.vendor_id
               AND ml3.lookup_type = 'MRP_SOURCE_TYPE'
               AND ml3.lookup_code = mislv.sourcing_level
               AND mislv.sourcing_level =
                      (SELECT MIN (sourcing_level)
                         FROM mrp_item_sourcing_levels_v
                        WHERE inventory_item_id = msib.inventory_item_id
                          AND organization_id = msib.organization_id)
            UNION
            SELECT ood.organization_code default_supplier
              FROM mrp_item_sourcing_levels_v mislv,
                   mfg_lookups ml1,
                   mfg_lookups ml2,
                   mfg_lookups ml3,
                   mtl_system_items_b msib,
                   org_organization_definitions ood
             WHERE msib.segment1 = :b1
               AND msib.organization_id = :b2
               AND mislv.inventory_item_id = msib.inventory_item_id
               AND mislv.organization_id = msib.organization_id
               AND ml1.lookup_type = 'MRP_SOURCING_RULE_TYPE'
               AND ml1.lookup_code = mislv.sourcing_rule_type
               AND ml2.lookup_type = 'MRP_ASSIGNMENT_TYPE'
               AND ml2.lookup_code = mislv.assignment_type
               AND ml3.lookup_type = 'MRP_SOURCE_TYPE'
               AND ml3.lookup_code = mislv.sourcing_level
               AND ood.organization_id = mislv.source_organization_id
               AND mislv.sourcing_level =
                      (SELECT MIN (sourcing_level)
                         FROM mrp_item_sourcing_levels_v
                        WHERE inventory_item_id = msib.inventory_item_id
                          AND organization_id = msib.organization_id))
    From the trace files, we see that the issue is with the seeded view, mrp_item_sourcing_levels_v.
    Need pointers for fixing the performance.    

    The ETRM says this about the view:
    ***** Warning: Oracle Internal Use Only *****
    Oracle Corporation does not support access to Oracle
    applications data using this object, except from standard Oracle Applications programs.
    which is a powerful suggestion that you should not be addressing this view directly. Looking at the source code for the view, it has a bunch of UNIONs that may prevent view merging, and all the queries have loads of hints coded within them. So really, there is little you can do about this.
    It looks pretty simple to re-write your query to avoid addressing this view, you are using it only to retrieve a couple of columns. If you look at the source code for the view you'll see that you can get them easily without going through the view.
    John Watson
    Oracle Certified Master DBA

  • The query HANGS for ever!

    hi,
    we have types which extend other types. We need this as a part of a framework in db. Over the paret type are the queue (oracle AQs) defined.
    Intermitantly, on few databases, when we try to create a type extending the same parent type with the queues running, the create type script just hangs off for ever.
    WHy does this happen? more importatly intermitantly?
    is there an approach to debug such issues? or get things working by killing some sessions etc.
    Any ideas/ pointers .. please help.
    db details:
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    CORE     10.2.0.4.0     Production
    TNS for Linux: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    thank u for the reply.
    Is there a way to figure out what objects are pinned. and if i figure out them then how do i un-pin them?
    But i have a type extending a type. To the best of my knowledge the objects created over types are locked (or pined). The paret type is just a declaration/ definition of how the object has to be created.

  • Query running for a long time

    Can some help me please below query has been running for a long time I am unable to fix it
    SELECT lmt.tab, pr.tab6, pr.tab7,
               pr.activity_id, pr.resource_id, lmt.tab2,
                lmt.tab5, pr.txn_lmt_trans_id, pr.analysis_type,
                pr.resource_type, pr.resource_category, pr.resource_sub_cat,
                pr.trans_dt, cd.start_dt, cd.end_dt, pr.currency_cd, pr.rt_type,
                pr.resource_quantity, pr.resource_amount, pr.foreign_amount,
                pr.foreign_currency, 2, 'S', pr.resource_id_from,
                hdr.contract_sign_dt, cd.retainage_id, cd.discount_id, 0, 0,
           cd.limit_bi_cntrl_flg, hdr.ca_rqst_src, 0, hdr.currency_cd,
           hdr.rt_type, 0, 0, pr.bi_distrib_status, pr.gl_distrib_status
         FROM ps_c1 lmt, ps_c2 hdr,  ps_c3 cd,
                ps_c4 pr
             WHERE lmt.tab = 836626
               AND hdr.tab2 = lmt.tab2
               AND cd.tab2 = lmt.tab2
               AND cd.tab5 = lmt.tab5
               AND cd.pricing_structure = 'RATE'
               AND pr.tab6 = cd.tab6_pc
               AND pr.tab2 = cd.tab2
               AND pr.tab5 = cd.tab5
               AND (pr.analysis_type IN ('BIL', 'OLT', 'PMR', 'ROL')
               AND pr.bi_distrib_status <> 'I'
               OR  pr.analysis_type = 'REV'
               AND pr.gl_distrib_status IN ('C', 'N'))
               AND NOT pr.ca_fee_status IN ('2', '3', '4', '5')
               AND 0 >= (SELECT count(*)
                        FROM ps_ca_lmt4_tao4 lmt4
                        WHERE lmt4.tab = 836626
                          AND lmt4.tab6 = pr.tab6
                          AND lmt4.tab7 = pr.tab7
                          AND lmt4.activity_id = pr.activity_id
                          AND lmt4.resource_id = pr.resource_id))
    Below is the execution plan
    ID    PID    Operation    Name    Rows    Bytes    Cost    CPU Cost    IO Cost    Temp space    IN-OUT    PQ Dist    PStart    PStop
    0        SELECT STATEMENT        2     598     99885     2G    99823                          
    1    0      NESTED LOOPS                                                       
    2    1        NESTED LOOPS        1     299     99885     2G    99823                          
    3    2          NESTED LOOPS        1     264     99883     2G    99821                          
    4    3            NESTED LOOPS        3     273     8     114779     8                          
    5    4              INDEX RANGE SCAN     ps_c1    6     138     1     8321     1                          
    6    4              TABLE ACCESS BY INDEX ROWID    ps_c3    1     68     2     17743     2                          
    7    6                INDEX UNIQUE SCAN    ps_c3    1          1     9021     1                          
    8    3            TABLE ACCESS BY INDEX ROWID    ps_c4    1     173     33292     671M    33271                          
    9    8              INDEX RANGE SCAN    ps_c4    55808          10139     320M    10129                          
    10    9                INDEX UNIQUE SCAN    PS_CA_LMT4_TAO4    1     46     0     1050     0                          
    11    2          INDEX UNIQUE SCAN    ps_c2    1          1     9021     1                          
    12    1        TABLE ACCESS BY INDEX ROWID    ps_c2    1     35     2     17413     2
    Can someone please help its really kind of urgent

    check the cardinalities: the CBO expects to access only a few rows and uses a lot of NL joins - and that's probably not the best solution. You could start with a llok at the cardinality of step 5, the index range scan on ps_c1. The CBO expects only 6 rows - is this a good guess? Of course you could just create a plan with rowsource statistics (gather_plan_statistics hint) and compare E- and A-rows.

  • My sql query running for more than 4 hours could some one please help me

    Hi ,
    I have one sql executable and the query is running for more than 4 hours . Could some one please help me in tuning the sql.
    The stats and all the general stuff is intact at db level :
    SELECT pasl.item_id item_id
    , pv.vendor_name vendor_name
    , msif.segment1 item
    , NVL(cic.item_cost,0) item_cost
    , NVL(pasl.attribute1,0) asl_cost
    FROM apps.mtl_system_items_b msif
    , apps.po_approved_supplier_list pasl
    , apps.cst_item_cost_type_v cic
    , apps.po_vendors pv
    , apps.po_asl_statuses past
    , apps.mtl_item_categories mic
    , apps.mtl_categories_b mc
    , apps.mtl_category_sets_b mcb
    , apps.mtl_category_sets_b mcbm
    , apps.mtl_categories_b mcm
    , apps.mtl_item_categories micm
    WHERE pasl.item_id = msif.inventory_item_id
    AND msif.inventory_item_id = cic.inventory_item_id
    AND msif.inventory_item_status_code in ('Active','ENG HOLD')
    AND cic.cost_type = 'Frozen'
    AND msif.organization_id = cic.organization_id
    AND EXISTS (SELECT 1
    FROM apps.mtl_system_items_b msin,
    apps.mtl_parameters mpn,
    apps.org_organization_definitions oodn
    WHERE msin.organization_id = mpn.organization_id
    AND mpn.organization_id = oodn.organization_id
    AND msin.inventory_item_id = msif.inventory_item_id
    AND oodn.operating_unit = :p_ou
    AND cic.organization_id = 87
    AND NVL(pv.end_date_active,TRUNC(SYSDATE+1)) > TRUNC(SYSDATE)
    AND pv.vendor_id = pasl.vendor_id
    AND mcbm.structure_id = mcm.structure_id
    AND nvl(mcm.start_date_active, (SYSDATE - 1)) < SYSDATE
    AND nvl(mcm.end_date_active, (SYSDATE + 1)) > SYSDATE
    AND mcbm.category_set_id = 1
    AND micm.inventory_item_id = msif.inventory_item_id
    AND micm.organization_id = msif.organization_id
    AND micm.category_set_id = mcbm.category_set_id
    AND micm.category_id = mcm.category_id
    AND (SUBSTR(mcm.segment1,1,2) = 'FG' OR msif.item_type LIKE 'FG%')
    AND mcm.segment3 NOT IN ('4','5','9','A')
    AND mcb.structure_id = mc.structure_id
    AND NVL(mc.start_date_active, (SYSDATE - 1)) < SYSDATE
    AND nvl(mc.end_date_active, (SYSDATE + 1)) > SYSDATE
    AND mcb.category_set_id = 1100000022
    AND mic.inventory_item_id = msif.inventory_item_id
    AND mic.organization_id = msif.organization_id
    AND mic.category_set_id = mcb.category_set_id
    AND mic.category_id = mc.category_id
    AND SUBSTR(mc.segment2,1,2) = pv.attribute6
    AND ROUND(NVL(pasl.attribute1,0),2) <> ROUND(NVL(cic.item_cost,0),2)
    AND pasl.asl_status_id = past.status_id
    AND UPPER(past.status) = 'APPROVED'
    --and    pv.attribute6 not in('IN','BG','CT')
    and    msif.inventory_item_id = :p_item_id42737
    UNION
    SELECT pasl.item_id item_id
    , pv.vendor_name vendor_name
    , msif.segment1 item
    , NVL(cic.item_cost,0) item_cost
    , NVL(pasl.attribute1,0) asl_cost
    FROM apps.mtl_system_items_fvl msif
    , apps.po_approved_supplier_list pasl
    , apps.cst_item_cost_type_v cic
    , apps.po_vendors pv
    , apps.po_asl_statuses past
    , apps.mtl_item_categories mic
    , apps.mtl_categories_b mc
    , apps.mtl_category_sets_b mcb
    , apps.mtl_category_sets_b mcbm
    , apps.mtl_categories_b mcm
    , apps.mtl_item_categories micm
    WHERE pasl.item_id = msif.inventory_item_id
    AND msif.inventory_item_id = cic.inventory_item_id
    AND msif.inventory_item_status_code in ('Active','ENG HOLD')
    AND cic.cost_type = 'Frozen'
    AND msif.organization_id = cic.organization_id
    AND EXISTS (SELECT 1
    FROM apps.mtl_system_items_b msin,
    apps.mtl_parameters mpn,
    apps.org_organization_definitions oodn
    WHERE msin.organization_id = mpn.organization_id
    AND mpn.organization_id = oodn.organization_id
    AND msin.inventory_item_id = msif.inventory_item_id
    AND oodn.operating_unit = :p_ou
    AND cic.organization_id = 87
    AND NVL(pv.end_date_active,TRUNC(SYSDATE+1)) > TRUNC(SYSDATE)
    AND pv.vendor_id = pasl.vendor_id
    AND mcbm.structure_id = mcm.structure_id
    AND NVL(mcm.start_date_active,(SYSDATE - 1)) < SYSDATE
    AND NVL(mcm.end_date_active, (SYSDATE + 1)) > SYSDATE
    AND mcbm.category_set_id = 1
    AND micm.inventory_item_id = msif.inventory_item_id
    AND micm.organization_id = msif.organization_id
    AND micm.category_set_id = mcbm.category_set_id
    AND micm.category_id = mcm.category_id
    AND (SUBSTR(mcm.segment1,1,2) = 'FG' OR msif.item_type LIKE 'FG%')
    AND mcm.segment3 NOT IN ('4','5','9','A')
    AND mcb.structure_id = mc.structure_id
    AND NVL(mc.start_date_active,(SYSDATE - 1)) < SYSDATE
    AND nvl(mc.end_date_active,(SYSDATE + 1)) > SYSDATE
    AND mcb.category_set_id = 1100000022
    AND mic.inventory_item_id = msif.inventory_item_id
    AND mic.organization_id = msif.organization_id
    AND mic.category_set_id = mcb.category_set_id
    AND mic.category_id = mc.category_id
    AND SUBSTR(mc.segment2,1,2) = pv.attribute6
    AND pasl.asl_status_id = past.status_id
    AND UPPER(past.status) = 'APPROVED'
    --and pv.attribute6 not in('IN','BG','CT')
    AND NVL(pasl.attribute1,0) = 0
    AND NVL(cic.item_cost,0) != 0
    and    msif.inventory_item_id = :p_item_id42737
    The execution plan displayed in taod is as below :
    Plan
    SELECT STATEMENT ALL_ROWSCost: 464 Bytes: 905 Cardinality: 2                                                                                                                                                                      
         140 SORT UNIQUE Cost: 464 Bytes: 905 Cardinality: 2                                                                                                                                                                 
              139 UNION-ALL                                                                                                                                                            
                   69 NESTED LOOPS Cost: 185 Bytes: 446 Cardinality: 1                                                                                                                                                       
                        67 NESTED LOOPS OUTER Cost: 180 Bytes: 444 Cardinality: 1                                                                                                                                                  
                             65 NESTED LOOPS Cost: 178 Bytes: 408 Cardinality: 1                                                                                                                                             
                                  63 NESTED LOOPS Cost: 177 Bytes: 404 Cardinality: 1                                                                                                                                        
                                       60 NESTED LOOPS Cost: 176 Bytes: 378 Cardinality: 1                                                                                                                                   
                                            57 NESTED LOOPS Cost: 174 Bytes: 353 Cardinality: 1                                                                                                                              
                                                 55 NESTED LOOPS Cost: 174 Bytes: 349 Cardinality: 1                                                                                                                         
                                                      53 NESTED LOOPS Cost: 174 Bytes: 342 Cardinality: 1                                                                                                                    
                                                           50 NESTED LOOPS Cost: 173 Bytes: 336 Cardinality: 1                                                                                                               
                                                                48 NESTED LOOPS Cost: 173 Bytes: 332 Cardinality: 1                                                                                                          
                                                                     46 FILTER                                                                                                     
                                                                          45 NESTED LOOPS OUTER Cost: 171 Bytes: 322 Cardinality: 1                                                                                                
                                                                               43 NESTED LOOPS Cost: 169 Bytes: 305 Cardinality: 1                                                                                           
                                                                                    41 NESTED LOOPS Cost: 168 Bytes: 292 Cardinality: 1                                                                                      
                                                                                         38 NESTED LOOPS Cost: 166 Bytes: 277 Cardinality: 1                                                                                 
                                                                                              36 NESTED LOOPS Cost: 166 Bytes: 273 Cardinality: 1                                                                            
                                                                                                   33 NESTED LOOPS Cost: 165 Bytes: 256 Cardinality: 1                                                                       
                                                                                                        30 NESTED LOOPS Cost: 162 Bytes: 237 Cardinality: 1                                                                  
                                                                                                             27 NESTED LOOPS Cost: 161 Bytes: 203 Cardinality: 1                                                             
                                                                                                                  24 NESTED LOOPS Cost: 159 Bytes: 185 Cardinality: 1                                                        
                                                                                                                       22 NESTED LOOPS Cost: 158 Bytes: 163 Cardinality: 1                                                   
                                                                                                                            19 NESTED LOOPS Cost: 156 Bytes: 117 Cardinality: 1                                              
                                                                                                                                 16 NESTED LOOPS Cost: 90 Bytes: 95 Cardinality: 1                                         
                                                                                                                                      13 NESTED LOOPS Cost: 49 Bytes: 72 Cardinality: 1                                    
                                                                                                                                           10 NESTED LOOPS Cost: 8 Bytes: 41 Cardinality: 1                               
                                                                                                                                                8 NESTED LOOPS Cost: 3 Bytes: 30 Cardinality: 1                          
                                                                                                                                                     5 NESTED LOOPS Cost: 2 Bytes: 22 Cardinality: 1                     
                                                                                                                                                          2 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORY_SETS_B Cost: 1 Bytes: 11 Cardinality: 1                
                                                                                                                                                               1 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_CATEGORY_SETS_B_U1 Cost: 0 Cardinality: 1           
                                                                                                                                                          4 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORY_SETS_B Cost: 1 Bytes: 11 Cardinality: 1                
                                                                                                                                                               3 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_CATEGORY_SETS_B_U1 Cost: 0 Cardinality: 1           
                                                                                                                                                     7 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_DEFAULT_CATEGORY_SETS Cost: 1 Bytes: 8 Cardinality: 1                     
                                                                                                                                                          6 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_DEFAULT_CATEGORY_SETS_U1 Cost: 0 Cardinality: 1                
                                                                                                                                                9 TABLE ACCESS FULL TABLE PO.PO_ASL_STATUSES Cost: 5 Bytes: 11 Cardinality: 1                          
                                                                                                                                           12 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORIES_B Cost: 41 Bytes: 93 Cardinality: 3                               
                                                                                                                                                11 INDEX RANGE SCAN INDEX INV.MTL__CATEGORIES_B_N2 Cost: 3 Cardinality: 1,426                          
                                                                                                                                      15 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORIES_B Cost: 41 Bytes: 92 Cardinality: 4                                    
                                                                                                                                           14 INDEX RANGE SCAN INDEX INV.MTL__CATEGORIES_B_N2 Cost: 3 Cardinality: 1,426                               
                                                                                                                                 18 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_ITEM_CATEGORIES Cost: 65 Bytes: 22 Cardinality: 1                                         
                                                                                                                                      17 INDEX RANGE SCAN INDEX INV.MTL_ITEM_CATEGORIES_N3 Cost: 2 Cardinality: 293                                    
                                                                                                                            21 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 46 Cardinality: 1                                              
                                                                                                                                 20 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1                                         
                                                                                                                       23 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 1 Bytes: 22 Cardinality: 1                                                   
                                                                                                                  26 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_APPROVED_SUPPLIER_LIST Cost: 2 Bytes: 18 Cardinality: 1                                                        
                                                                                                                       25 INDEX RANGE SCAN INDEX PO.PO_APPROVED_SUPPLIER_LIST_N1 Cost: 1 Cardinality: 1                                                   
                                                                                                             29 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_VENDORS Cost: 1 Bytes: 34 Cardinality: 1                                                             
                                                                                                                  28 INDEX UNIQUE SCAN INDEX (UNIQUE) PO.PO_VENDORS_U1 Cost: 0 Cardinality: 1                                                        
                                                                                                        32 TABLE ACCESS BY INDEX ROWID TABLE BOM.CST_ITEM_COSTS Cost: 3 Bytes: 19 Cardinality: 1                                                                  
                                                                                                             31 INDEX RANGE SCAN INDEX (UNIQUE) BOM.CST_ITEM_COSTS_U1 Cost: 2 Cardinality: 1                                                             
                                                                                                   35 TABLE ACCESS BY INDEX ROWID TABLE BOM.CST_COST_TYPES Cost: 1 Bytes: 17 Cardinality: 1                                                                       
                                                                                                        34 INDEX UNIQUE SCAN INDEX (UNIQUE) BOM.CST_COST_TYPES_U1 Cost: 0 Cardinality: 1                                                                  
                                                                                              37 INDEX UNIQUE SCAN INDEX (UNIQUE) BOM.CST_COST_TYPES_U1 Cost: 0 Bytes: 4 Cardinality: 1                                                                            
                                                                                         40 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 15 Cardinality: 1                                                                                 
                                                                                              39 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1                                                                            
                                                                                    42 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_TL_U1 Cost: 1 Bytes: 13 Cardinality: 1                                                                                      
                                                                               44 INDEX RANGE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 2 Bytes: 17 Cardinality: 1                                                                                           
                                                                     47 INDEX RANGE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 2 Bytes: 30 Cardinality: 3                                                                                                     
                                                                49 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_PARAMETERS_U1 Cost: 0 Bytes: 4 Cardinality: 1                                                                                                          
                                                           52 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ALL_ORGANIZATION_UNITS Cost: 1 Bytes: 6 Cardinality: 1                                                                                                               
                                                                51 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ORGANIZATION_UNITS_PK Cost: 0 Cardinality: 1                                                                                                          
                                                      54 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ALL_ORGANIZATION_UNTS_TL_PK Cost: 0 Bytes: 7 Cardinality: 1                                                                                                                    
                                                 56 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_PARAMETERS_U1 Cost: 0 Bytes: 4 Cardinality: 1                                                                                                                         
                                            59 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 2 Bytes: 25 Cardinality: 1                                                                                                                              
                                                 58 INDEX RANGE SCAN INDEX HR.HR_ORGANIZATION_INFORMATIO_FK2 Cost: 1 Cardinality: 1                                                                                                                         
                                       62 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 1 Bytes: 26 Cardinality: 1                                                                                                                                   
                                            61 INDEX RANGE SCAN INDEX HR.HR_ORGANIZATION_INFORMATIO_FK2 Cost: 1 Cardinality: 1                                                                                                                              
                                  64 INDEX FULL SCAN INDEX (UNIQUE) GL.GL_SETS_OF_BOOKS_U2 Cost: 1 Bytes: 4 Cardinality: 1                                                                                                                                        
                             66 INDEX RANGE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 2 Bytes: 36 Cardinality: 1                                                                                                                                             
                        68 TABLE ACCESS FULL TABLE APPLSYS.FND_PRODUCT_GROUPS Cost: 5 Bytes: 2 Cardinality: 1                                                                                                                                                  
                   138 NESTED LOOPS Cost: 278 Bytes: 459 Cardinality: 1                                                                                                                                                       
                        136 NESTED LOOPS Cost: 277 Bytes: 449 Cardinality: 1                                                                                                                                                  
                             134 NESTED LOOPS Cost: 277 Bytes: 445 Cardinality: 1                                                                                                                                             
                                  132 NESTED LOOPS Cost: 277 Bytes: 441 Cardinality: 1                                                                                                                                        
                                       129 NESTED LOOPS Cost: 275 Bytes: 415 Cardinality: 1                                                                                                                                   
                                            127 NESTED LOOPS Cost: 275 Bytes: 408 Cardinality: 1                                                                                                                              
                                                 124 NESTED LOOPS Cost: 274 Bytes: 402 Cardinality: 1                                                                                                                         
                                                      122 NESTED LOOPS Cost: 273 Bytes: 398 Cardinality: 1                                                                                                                    
                                                           120 MERGE JOIN CARTESIAN Cost: 268 Bytes: 373 Cardinality: 1                                                                                                               
                                                                117 FILTER                                                                                                          
                                                                     116 NESTED LOOPS OUTER Cost: 263 Bytes: 371 Cardinality: 1                                                                                                     
                                                                          114 NESTED LOOPS Cost: 261 Bytes: 354 Cardinality: 1                                                                                                
                                                                               112 NESTED LOOPS OUTER Cost: 260 Bytes: 341 Cardinality: 1                                                                                           
                                                                                    110 NESTED LOOPS Cost: 258 Bytes: 305 Cardinality: 1                                                                                      
                                                                                         107 NESTED LOOPS Cost: 256 Bytes: 290 Cardinality: 1                                                                                 
                                                                                              105 NESTED LOOPS Cost: 256 Bytes: 286 Cardinality: 1                                                                            
                                                                                                   102 NESTED LOOPS Cost: 255 Bytes: 269 Cardinality: 1                                                                       
                                                                                                        99 NESTED LOOPS Cost: 252 Bytes: 250 Cardinality: 1                                                                  
                                                                                                             97 NESTED LOOPS Cost: 251 Bytes: 237 Cardinality: 1                                                             
                                                                                                                  95 NESTED LOOPS Cost: 250 Bytes: 215 Cardinality: 1                                                        
                                                                                                                       93 NESTED LOOPS Cost: 249 Bytes: 193 Cardinality: 1                                                   
                                                                                                                            90 NESTED LOOPS Cost: 245 Bytes: 294 Cardinality: 2                                              
                                                                                                                                 87 HASH JOIN Cost: 230 Bytes: 387 Cardinality: 3                                         
                                                                                                                                      85 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORIES_B Cost: 41 Bytes: 92 Cardinality: 4                                    
                                                                                                                                           84 NESTED LOOPS Cost: 90 Bytes: 95 Cardinality: 1                               
                                                                                                                                                82 NESTED LOOPS Cost: 49 Bytes: 72 Cardinality: 1                          
                                                                                                                                                     79 NESTED LOOPS Cost: 8 Bytes: 41 Cardinality: 1                     
                                                                                                                                                          77 NESTED LOOPS Cost: 3 Bytes: 30 Cardinality: 1                
                                                                                                                                                               74 NESTED LOOPS Cost: 2 Bytes: 22 Cardinality: 1           
                                                                                                                                                                    71 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORY_SETS_B Cost: 1 Bytes: 11 Cardinality: 1      
                                                                                                                                                                         70 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_CATEGORY_SETS_B_U1 Cost: 0 Cardinality: 1
                                                                                                                                                                    73 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORY_SETS_B Cost: 1 Bytes: 11 Cardinality: 1      
                                                                                                                                                                         72 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_CATEGORY_SETS_B_U1 Cost: 0 Cardinality: 1
                                                                                                                                                               76 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_DEFAULT_CATEGORY_SETS Cost: 1 Bytes: 8 Cardinality: 1           
                                                                                                                                                                    75 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_DEFAULT_CATEGORY_SETS_U1 Cost: 0 Cardinality: 1      
                                                                                                                                                          78 TABLE ACCESS FULL TABLE PO.PO_ASL_STATUSES Cost: 5 Bytes: 11 Cardinality: 1                
                                                                                                                                                     81 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_CATEGORIES_B Cost: 41 Bytes: 93 Cardinality: 3                     
                                                                                                                                                          80 INDEX RANGE SCAN INDEX INV.MTL__CATEGORIES_B_N2 Cost: 3 Cardinality: 1,426                
                                                                                                                                                83 INDEX RANGE SCAN INDEX INV.MTL__CATEGORIES_B_N2 Cost: 3 Cardinality: 1,426                          
                                                                                                                                      86 TABLE ACCESS FULL TABLE PO.PO_VENDORS Cost: 139 Bytes: 15,980 Cardinality: 470                                    
                                                                                                                                 89 TABLE ACCESS BY INDEX ROWID TABLE PO.PO_APPROVED_SUPPLIER_LIST Cost: 13 Bytes: 18 Cardinality: 1                                         
                                                                                                                                      88 INDEX RANGE SCAN INDEX PO.PO_APPROVED_SUPPLIER_LIST_N3 Cost: 1 Cardinality: 64                                    
                                                                                                                            92 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 46 Cardinality: 1                                              
                                                                                                                                 91 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1                                         
                                                                                                                       94 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 1 Bytes: 22 Cardinality: 1                                                   
                                                                                                                  96 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 1 Bytes: 22 Cardinality: 1                                                        
                                                                                                             98 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_TL_U1 Cost: 1 Bytes: 13 Cardinality: 1                                                             
                                                                                                        101 TABLE ACCESS BY INDEX ROWID TABLE BOM.CST_ITEM_COSTS Cost: 3 Bytes: 19 Cardinality: 1                                                                  
                                                                                                             100 INDEX RANGE SCAN INDEX (UNIQUE) BOM.CST_ITEM_COSTS_U1 Cost: 2 Cardinality: 1                                                             
                                                                                                   104 TABLE ACCESS BY INDEX ROWID TABLE BOM.CST_COST_TYPES Cost: 1 Bytes: 17 Cardinality: 1                                                                       
                                                                                                        103 INDEX UNIQUE SCAN INDEX (UNIQUE) BOM.CST_COST_TYPES_U1 Cost: 0 Cardinality: 1                                                                  
                                                                                              106 INDEX UNIQUE SCAN INDEX (UNIQUE) BOM.CST_COST_TYPES_U1 Cost: 0 Bytes: 4 Cardinality: 1                                                                            
                                                                                         109 TABLE ACCESS BY INDEX ROWID TABLE INV.MTL_SYSTEM_ITEMS_B Cost: 2 Bytes: 15 Cardinality: 1                                                                                 
                                                                                              108 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Cardinality: 1                                                                            
                                                                                    111 INDEX RANGE SCAN INDEX (UNIQUE) APPLSYS.FND_LOOKUP_VALUES_U1 Cost: 2 Bytes: 36 Cardinality: 1                                                                                      
                                                                               113 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_TL_U1 Cost: 1 Bytes: 13 Cardinality: 1                                                                                           
                                                                          115 INDEX RANGE SCAN INDEX (UNIQUE) INV.MTL_ITEM_CATEGORIES_U1 Cost: 2 Bytes: 17 Cardinality: 1                                                                                                
                                                                119 BUFFER SORT Cost: 266 Bytes: 2 Cardinality: 1                                                                                                          
                                                                     118 TABLE ACCESS FULL TABLE APPLSYS.FND_PRODUCT_GROUPS Cost: 5 Bytes: 2 Cardinality: 1                                                                                                     
                                                           121 TABLE ACCESS FULL TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 5 Bytes: 25 Cardinality: 1                                                                                                               
                                                      123 INDEX FULL SCAN INDEX (UNIQUE) GL.GL_SETS_OF_BOOKS_U2 Cost: 1 Bytes: 4 Cardinality: 1                                                                                                                    
                                                 126 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ALL_ORGANIZATION_UNITS Cost: 1 Bytes: 6 Cardinality: 1                                                                                                                         
                                                      125 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ORGANIZATION_UNITS_PK Cost: 0 Cardinality: 1                                                                                                                    
                                            128 INDEX UNIQUE SCAN INDEX (UNIQUE) HR.HR_ALL_ORGANIZATION_UNTS_TL_PK Cost: 0 Bytes: 7 Cardinality: 1                                                                                                                              
                                       131 TABLE ACCESS BY INDEX ROWID TABLE HR.HR_ORGANIZATION_INFORMATION Cost: 2 Bytes: 26 Cardinality: 1                                                                                                                                   
                                            130 INDEX RANGE SCAN INDEX HR.HR_ORGANIZATION_INFORMATIO_FK2 Cost: 1 Cardinality: 1                                                                                                                              
                                  133 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_PARAMETERS_U1 Cost: 0 Bytes: 4 Cardinality: 1                                                                                                                                        
                             135 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_PARAMETERS_U1 Cost: 0 Bytes: 4 Cardinality: 1                                                                                                                                             
                        137 INDEX UNIQUE SCAN INDEX (UNIQUE) INV.MTL_SYSTEM_ITEMS_B_U1 Cost: 1 Bytes: 10 Cardinality: 1                                                                                                                                                  
    Regards,
    Siva.

    Welcome to the forums !
    Pl post details of OS, database and EBS versions.
    Pl see these threads on how to post a tuning request -
    HOW TO: Post a SQL statement tuning request - template posting
    When your query takes too long ...
    HTH
    Srini

  • Update query run for too long

    Oracle Database 11.1.0.7.0
    UPDATE DTC SET NEW_KY=(SELECT DCTT.KY FROM DCTT WHERE DCTT.KY = DTC.KY),
    NEW_KY_ID=(SELECT DCTT.KY_ID FROM DCTT WHERE DCTT.KY = DTC.KY) where
    EXISTS ( SELECT 1 FROM DCTT WHERE DCTT.KY = DTC.KY and NEW_KY IS NULL ) and rownum<100000
    both dtc and dctt have 8-9 millions of records.
    I tried merge also.It also run indefinitely
    I want to update table in batch of 100K batches.
    for dctt ky column is primary key.
    for dtc ky column is non-primary and also dont have index on it.
    What should i do to run it faster.Any idea.Thanks

    UPDATE dtc
    SET    new_ky = (SELECT dctt.ky
                     FROM   dctt
                     WHERE  dctt.ky = dtc.ky),
           new_ky_id = (SELECT dctt.ky_id
                        FROM   dctt
                        WHERE  dctt.ky = dtc.ky)
    WHERE  EXISTS (SELECT 1
                   FROM   dctt
                   WHERE  dctt.ky = dtc.ky
                          AND new_ky IS NULL)
           AND ROWNUM < 100000
    AND new_ky IS NULLabove forces FTS for every row

  • What are the areas impact query to run for ever/long?

    Hi All,
    When I have to talk about long running scripts or procedures I focus on DTA which suggests on Indexing and infact I think this is the main cause. What are the other areas which we need to consider for Long running queries and troubleshooting tools we need
    to use do you think?
    Ofcourse blocking impacts but am purely thinking at query perspective.
    Thanks
    Swapna

    What are the other areas which we need to consider for Long running queries and troubleshooting tools we need to use do you think?
    One of the reasons is blocking. Please take a look at these links:
    INF: Understanding and resolving SQL Server blocking problems
    Troubleshoot Slow-Running Queries In SQL Server
    T-SQL Articles
    T-SQL e-book by TechNet Wiki Community
    T-SQL blog

  • How can i make this query run for a form

    This query works fine for a sql report
    SELECT *
    FROM STUDENTS
    WHERE given_name||' '||family_name = :P101_USERNAME
    AND password = :P101_PASSWORD;
    But i want it to do the same thing for a form but i dont have the option like i do for the report where i can just apply the condition to the process.
    Anyone any ideas how i could do this so that when i go to the form this information is already there based on the username and password from the previous page?

    Assuming that page 101 is your login form, just lookup the primary key of the student based on the values presented in the login page fields, then set and pass this value to the form page.
    So you would create a process that runs near the very end of the the login processes on page 101, something like this:
    declare
    l_student_id students.student_id%TYPE;
    begin
    select student_id into l_student_id from students where  given_name||' '||family_name = :P101_USERNAME and password = :P101_PASSWORD;
    -- then set the value of your form page primary key field
    :P1_STUDENT_ID := l_student_id;
    end;I've done something similar and it works fine for me, although I haven't looked at it recently.
    Earl

  • Query running for too long

    Hi All,
    Can someone pls help me in finding how long will it take to execute the below query.
    I have a query that is taking too long to execute.
    SELECT   CPU_TIME/1000000/60 CPUTIME, ELAPSED_TIME/1000000/60 ELAPSEDTIME, PROGRAM_LINE#, OPTIMIZER_COST,
    USER_IO_WAIT_TIME/1000000/60 IOWAITTIME,  DISK_READS, DIRECT_WRITES, BUFFER_GETS, to_char(Q.SQL_FULLTEXT), OPTIMIZER_MODE,  SHARABLE_MEM, PERSISTENT_MEM, RUNTIME_MEM, SORTS, FETCHES, EXECUTIONS, END_OF_FETCH_COUNT, USERS_EXECUTING, LOADS,
    FIRST_LOAD_TIME,  INVALIDATIONS, PARSE_CALLS, APPLICATION_WAIT_TIME, CONCURRENCY_WAIT_TIME, CLUSTER_WAIT_TIME,
    PLSQL_EXEC_TIME, JAVA_EXEC_TIME, ROWS_PROCESSED, COMMAND_TYPE, PARSING_USER_ID, PARSING_SCHEMA_ID, PARSING_SCHEMA_NAME, OBJECT_STATUS
         FROM     v$session S, v$sqlarea Q
         WHERE    S.SQL_ADDRESS = Q.ADDRESS
         AND      s.username = 'SCHEMA_NAME'
         AND       s.osuser = 'OSUSER_NAME';I can see CPU_TIME increasing. Is there any way that I can find how lmuch more time will it take for the query to execute.
    The query creates a table that has a sub query and inner query.
    rgds
    saaz

    http://www.gplivna.eu/papers/v$session_longops.htm
    There is a dynamic performance view v$session_longops that is populated for many long running operations in Oracle. The primary criterion for any operation to appear in v$session_longops is to run more than 6 seconds. Although this isn’t the only criterion as well as not all operations that take more than 6 seconds are shown in this view. For example one can find hash joins in v$session_longops, but you won’t find there nested loop joins even if they are longer than 6 seconds and are joining very big data sets.

  • Materialised view runs for ever ...

    Hi
    I'd appreciate if someone could shine some light on an issue I'm having with a materialised view.
    I inherited this when I came into my current project, so before you ask me why tables are not partitioned or why a MV is being used for such a scenario, the answer is I don't know!!
    Anyway ... I'm using "Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod" running on SUSE ...
    There are a number of normalised tables two of which contain in the region of 400million rows each and tend to grow at the rate of 27000 rows per day.
    There's a materialised view (for the purposes of providing fast interactive reporting) that is setup as a normal join between 4 tables; the above two and the other two are just basic dictionary type lookups each containing around 100 or so rows.
    SELECT .... FROM LargeTable1, LargeTable2, Lookup3, Lookup4 WHERE Lookup3.ID=LargeTable1.LID and LargeTable2.ID=LargeTable1.ID and LargeTable2.LID=Lookup4.ID ;
    Running a FULL refresh on the MV failes with a 'ora-01555 snapshot too old' error after about 5 days!! Then takes around the same amount of time to rollback. Can't do a FAST refresh, I think because logs and/or mv indecies are out of sync.
    Table space is 63% full and undo space is set to auto-extend.
    I've tried /*+RULE */ but that doesn't seem to make a huge difference.
    Why does it take so long? Why does it fail? What can I do to speed it up?
    Thanks in advance for your assistance.
    Edited by: 883758 on Sep 7, 2011 2:16 PM

    You should approach this as a SQL tuning exercise, without the ability to change the query itself.
    Are table statistics up to date? Look at the execution plan – does it look reasonable for you? Are there any indexes that can help? (I am thinking covering indexes on the large tables …)
    Iordan Iotzov
    http://iiotzov.wordpress.com/

  • Job running for ever...

    Hi Gurus,
    I created a generic extractor and when execute it using RSA3 transaction in SRM, is OK.
    When i execute the function module is also OK.
    When i start a job (infopackage) using this extractor, the records are load in BI but the job still running...
    I saw in SM5O that the work process is reading a ROIS table...
    Why it it taking so long...it has only 20 records.
    Appreciate your response.
    Thanks,
    rCm.

    Hi,
    When a BI load takes long time to finish.It may be hanged in tRFC.
    Do the following steps.
    1.Go to the long running load monitor (T-code: RSMO) screen and from menu at top navigate to u2018Environmentu2018 -> u2018Transact. RFCu2018 and then,
    -> To u2018In the Data Warehouseu2018 , if the data source is in same SAP system as of the current load
    -> To u2018In the source systemu2018 , if the data source exists in external SAP system (like R/3).
    2.Now we will be in u2018Transactional RFCu2018 list selection screen. Here enter the input parameters. Put wild character asterisk u2018*u2019 in you need to get entire list of tRFCu2019s in the system.
    3.Now the screen will list all the tRFCs currently scheduled to execute or held up. If a tRFC is held for long time, then we can manually push it by clicking on it from the list and then from menu go to u2018Editu2018 -> u2018Execute LUWu2018 or pressing F6.
    Regards,
    Shiva.

Maybe you are looking for

  • [F8]Need to turn this gallery into a slide show

    I have some code from a "how to" used to create a photo gallery. This gallery was meant to be used with buttons but, what I need is for the images to fade in and out automatically. Not sure what code would allow that to happen. Im using this type of

  • Reconciliation of two accounts

    Hi dear all, I have some query about reconciliation of accounts,my client has defined different chart of accounts for invoice posting and invoice payment i.e.A/P invoice account for vendor is different and payment for the particular vendor code is di

  • Managing What Music Goes Onto Your iPod Touch

    Hello everyone, I would like to manually specify what podcasts, photos and movies get synced to my iPod. I would then like iTunes to fill up the remaining available space with either a random selection of albums or ones that I select. I must be thick

  • External Hard Drive not Mounting any more

    Hi all, I have noticed since couple of kernel updates, my external hard drive - plugged via USB doesn't get mounted any more. To access the drive I need to reboot the computer with the hard drive switch on. See below for the dmesg output, regular usb

  • Interpolation  from Raw or photoshop?

    Hi what you recommender interpolation from Raw or photoshop? or what best? Thank window XP photoshop cs3