Update statement takes too long to run

Hello,
I am running this simple update statement, but it takes too long to run. It was running for 16 hours and then I cancelled it. It was not even finished. The destination table that I am updating has 2.6 million records, but I am only updating 206K records. If add ROWNUM <20 to the update statement works just fine and updates the right column with the right information. Do you have any ideas what could be wrong in my update statement? I am also using a DB link since CAP.ESS_LOOKUP table resides in different db from the destination table. We are running 11g Oracle Db.
UPDATE DEV_OCS.DOCMETA IPM
SET IPM.XIPM_APP_2_17 = (SELECT DISTINCT LKP.DOC_STATUS
FROM [email protected] LKP
WHERE LKP.DOC_NUM = IPM.XIPM_APP_2_1 AND
IPM.XIPMSYS_APP_ID = 2
WHERE
IPM.XIPMSYS_APP_ID = 2;
Thanks,
Ilya

matthew_morris wrote:
In the first SQL, the SELECT against the remote table was a correlated subquery. the 'WHERE LKP.DOC_NUM = IPM.XIPM_APP_2_1 AND IPM.XIPMSYS_APP_ID = 2" means that the subquery had to run once for each row of DEV_OCS.DOCMETA being evaluated. This might have meant thousands of iterations, meaning a great deal of network traffic (not to mention each performing a DISTINCT operation). Queries where the data is split between two or more databases are much more expensive than queries using only tables in a single database.Sorry to disappoint you again, but with clause by itself doesn't prevent from "subquery had to run once for each row of DEV_OCS.DOCMETA being evaluated". For example:
{code}
SQL> set linesize 132
SQL> explain plan for
2 update emp e
3 set deptno = (select t.deptno from dept@sol10 t where e.deptno = t.deptno)
4 /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 3247731149
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Inst |IN-OUT|
| 0 | UPDATE STATEMENT | | 14 | 42 | 17 (83)| 00:00:01 | | |
| 1 | UPDATE | EMP | | | | | | |
| 2 | TABLE ACCESS FULL| EMP | 14 | 42 | 3 (0)| 00:00:01 | | |
| 3 | REMOTE | DEPT | 1 | 13 | 0 (0)| 00:00:01 | SOL10 | R->S |
PLAN_TABLE_OUTPUT
Remote SQL Information (identified by operation id):
3 - SELECT "DEPTNO" FROM "DEPT" "T" WHERE "DEPTNO"=:1 (accessing 'SOL10' )
16 rows selected.
SQL> explain plan for
2 update emp e
3 set deptno = (with t as (select * from dept@sol10) select t.deptno from t where e.deptno = t.deptno)
4 /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 3247731149
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Inst |IN-OUT|
| 0 | UPDATE STATEMENT | | 14 | 42 | 17 (83)| 00:00:01 | | |
| 1 | UPDATE | EMP | | | | | | |
| 2 | TABLE ACCESS FULL| EMP | 14 | 42 | 3 (0)| 00:00:01 | | |
| 3 | REMOTE | DEPT | 1 | 13 | 0 (0)| 00:00:01 | SOL10 | R->S |
PLAN_TABLE_OUTPUT
Remote SQL Information (identified by operation id):
3 - SELECT "DEPTNO" FROM "DEPT" "DEPT" WHERE "DEPTNO"=:1 (accessing 'SOL10' )
16 rows selected.
SQL>
{code}
As you can see, WITH clause by itself guaranties nothing. We must force optimizer to materialize it:
{code}
SQL> explain plan for
2 update emp e
3 set deptno = (with t as (select /*+ materialize */ * from dept@sol10) select t.deptno from t where e.deptno = t.deptno
4 /
Explained.
SQL> @?\rdbms\admin\utlxpls
PLAN_TABLE_OUTPUT
Plan hash value: 3568118945
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Inst |IN-OUT|
| 0 | UPDATE STATEMENT | | 14 | 42 | 87 (17)| 00:00:02 | | |
| 1 | UPDATE | EMP | | | | | | |
| 2 | TABLE ACCESS FULL | EMP | 14 | 42 | 3 (0)| 00:00:01 | | |
| 3 | TEMP TABLE TRANSFORMATION | | | | | | | |
| 4 | LOAD AS SELECT | SYS_TEMP_0FD9D6603_1CEEEBC | | | | | | |
| 5 | REMOTE | DEPT | 4 | 80 | 3 (0)| 00:00:01 | SOL10 | R->S |
PLAN_TABLE_OUTPUT
|* 6 | VIEW | | 4 | 52 | 2 (0)| 00:00:01 | | |
| 7 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6603_1CEEEBC | 4 | 80 | 2 (0)| 00:00:01 | | |
Predicate Information (identified by operation id):
6 - filter("T"."DEPTNO"=:B1)
Remote SQL Information (identified by operation id):
PLAN_TABLE_OUTPUT
5 - SELECT "DEPTNO","DNAME","LOC" FROM "DEPT" "DEPT" (accessing 'SOL10' )
25 rows selected.
SQL>
{code}
I do know hint materialize is not documented, but I don't know any other way besides splitting statement in two to materialize it.
SY.

Similar Messages

  • Update statement taking too long to execute

    Hi All,
    I'm trying to run this update statement. But its taking too long to execute.
        UPDATE ops_forecast_extract b SET position_id = (SELECT a.row_id
            FROM s_postn a
            WHERE UPPER(a.desc_text) = UPPER(TRIM(B.POSITION_NAME)))
            WHERE position_level = 7
            AND b.am_id IS NULL;
            SELECT COUNT(*) FROM S_POSTN;
            214665
            SELECT COUNT(*) FROM ops_forecast_extract;
            49366
    SELECT count(*)
            FROM s_postn a, ops_forecast_extract b
            WHERE UPPER(a.desc_text) = UPPER(TRIM(B.POSITION_NAME));
    575What could be the reason for update statement to execute so long?
    Thanks

    polasa wrote:
    Hi All,
    I'm trying to run this update statement. But its taking too long to execute.
    What could be the reason for update statement to execute so long?You haven't said what "too long" means, but a simple reason could be that the scalar subquery on "s_postn" is using a full table scan for each execution. Potentially this subquery gets executed for each row of the "ops_forecast_extract" table that satisfies your filter predicates. "Potentially" because of the cunning "filter/subquery optimization" of the Oracle runtime engine that attempts to cache the results of already executed instances of the subquery. Since the in-memory hash table that holds these cached results is of limited size, the optimization algorithm depends on the sort order of the data and could suffer from hash collisions it's unpredictable how well this optimization works in your particular case.
    You might want to check the execution plan, it should tell you at least how Oracle is going to execute the scalar subquery (it doesn't tell you anything about this "filter/subquery optimization" feature).
    Generic instructions how to generate a useful explain plan output and how to post it here follow:
    Could you please post an properly formatted explain plan output using DBMS_XPLAN.DISPLAY including the "Predicate Information" section below the plan to provide more details regarding your statement. Please use the {noformat}[{noformat}code{noformat}]{noformat} tag before and {noformat}[{noformat}/code{noformat}]{noformat} tag after or the {noformat}{{noformat}code{noformat}}{noformat} tag before and after to enhance readability of the output provided:
    In SQL*Plus:
    SET LINESIZE 130
    EXPLAIN PLAN FOR <your statement>;
    SELECT * FROM TABLE(DBMS_XPLAN.DISPLAY);Note that the package DBMS_XPLAN.DISPLAY is only available from 9i on.
    In 9i and above, if the "Predicate Information" section is missing from the DBMS_XPLAN.DISPLAY output but you get instead the message "Plan table is old version" then you need to re-create your plan table using the server side script "$ORACLE_HOME/rdbms/admin/utlxplan.sql".
    In previous versions you could run the following in SQL*Plus (on the server) instead:
    @?/rdbms/admin/utlxplsA different approach in SQL*Plus:
    SET AUTOTRACE ON EXPLAIN
    <run your statement>;will also show the execution plan.
    In order to get a better understanding where your statement spends the time you might want to turn on SQL trace as described here:
    When your query takes too long ...
    and post the "tkprof" output here, too.
    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/

  • SQL Update statement taking too long..

    Hi All,
    I have a simple update statement that goes through a table of 95000 rows that is taking too long to update; here are the details:
    Oracle Version: 11.2.0.1 64bit
    OS: Windows 2008 64bit
    desc temp_person;
    Name                                                                                Null?    Type
    PERSON_ID                                                                           NOT NULL NUMBER(10)
    DISTRICT_ID                                                                     NOT NULL NUMBER(10)
    FIRST_NAME                                                                                   VARCHAR2(60)
    MIDDLE_NAME                                                                                  VARCHAR2(60)
    LAST_NAME                                                                                    VARCHAR2(60)
    BIRTH_DATE                                                                                   DATE
    SIN                                                                                          VARCHAR2(11)
    PARTY_ID                                                                                     NUMBER(10)
    ACTIVE_STATUS                                                                       NOT NULL VARCHAR2(1)
    TAXABLE_FLAG                                                                                 VARCHAR2(1)
    CPP_EXEMPT                                                                                   VARCHAR2(1)
    EVENT_ID                                                                            NOT NULL NUMBER(10)
    USER_INFO_ID                                                                                 NUMBER(10)
    TIMESTAMP                                                                           NOT NULL DATE
    CREATE INDEX tmp_rs_PERSON_ED ON temp_person (PERSON_ID,DISTRICT_ID) TABLESPACE D_INDEX;
    Index created.
    ANALYZE INDEX tmp_PERSON_ED COMPUTE STATISTICS;
    Index analyzed.
    explain plan for update temp_person
      2  set first_name = (select trim(f_name)
      3                    from ext_names_csv
      4                               where temp_person.PERSON_ID=ext_names_csv.p_id
      5                               and   temp_person.DISTRICT_ID=ext_names_csv.ed_id);
    Explained.
    @?/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 3786226716
    | Id  | Operation                   | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT            |                | 82095 |  4649K|  2052K  (4)| 06:50:31 |
    |   1 |  UPDATE                     | TEMP_PERSON    |       |       |            |          |
    |   2 |   TABLE ACCESS FULL         | TEMP_PERSON    | 82095 |  4649K|   191   (1)| 00:00:03 |
    |*  3 |   EXTERNAL TABLE ACCESS FULL| EXT_NAMES_CSV  |     1 |   178 |    24   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - filter("EXT_NAMES_CSV"."P_ID"=:B1 AND "EXT_NAMES_CSV"."ED_ID"=:B2)
    Note
       - dynamic sampling used for this statement (level=2)
    19 rows selected.By the looks of it the update is going to take 6 hrs!!!
    ext_names_csv is an external table that have the same number of rows as the PERSON table.
    ROHO@rohof> desc ext_names_csv
    Name                                                                                Null?    Type
    P_ID                                                                                         NUMBER
    ED_ID                                                                                        NUMBER
    F_NAME                                                                                       VARCHAR2(300)
    L_NAME                                                                                       VARCHAR2(300)Anyone can help diagnose this please.
    Thanks
    Edited by: rsar001 on Feb 11, 2011 9:10 PM

    Thank you all for the great ideas, you have been extremely helpful. Here is what we did and were able to resolve the query.
    We started with Etbin's idea to create a table from the ext table so that we can index and reference easier than an external table, so we did the following:
    SQL> create table ext_person as select P_ID,ED_ID,trim(F_NAME) fst_name,trim(L_NAME) lst_name from EXT_NAMES_CSV;
    Table created.
    SQL> desc ext_person
    Name                                                                                Null?    Type
    P_ID                                                                                         NUMBER
    ED_ID                                                                                        NUMBER
    FST_NAME                                                                                     VARCHAR2(300)
    LST_NAME                                                                                     VARCHAR2(300)
    SQL> select count(*) from ext_person;
      COUNT(*)
         93383
    SQL> CREATE INDEX EXT_PERSON_ED ON ext_person (P_ID,ED_ID) TABLESPACE D_INDEX;
    Index created.
    SQL> exec dbms_stats.gather_index_stats(ownname=>'APPD', indname=>'EXT_PERSON_ED',partname=> NULL , estimate_percent=> 30 );
    PL/SQL procedure successfully completed.We had a look at the plan with the original SQL query that we had:
    SQL> explain plan for update temp_person
      2  set first_name = (select fst_name
      3                    from ext_person
      4                               where temp_person.PERSON_ID=ext_person.p_id
      5                               and   temp_person.DISTRICT_ID=ext_person.ed_id);
    Explained.
    SQL> @?/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 1236196514
    | Id  | Operation                    | Name           | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | UPDATE STATEMENT             |                | 93383 |  1550K|   186K (50)| 00:37:24 |
    |   1 |  UPDATE                      | TEMP_PERSON    |       |       |            |          |
    |   2 |   TABLE ACCESS FULL          | TEMP_PERSON    | 93383 |  1550K|   191   (1)| 00:00:03 |
    |   3 |   TABLE ACCESS BY INDEX ROWID| EXTT_PERSON    |     9 |  1602 |     1   (0)| 00:00:01 |
    |*  4 |    INDEX RANGE SCAN          | EXT_PERSON_ED  |     1 |       |     1   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("EXT_PERSON"."P_ID"=:B1 AND "RS_PERSON"."ED_ID"=:B2)
    Note
       - dynamic sampling used for this statement (level=2)
    20 rows selected.As you can see the time has dropped to 37min (from 6 hrs). Then we decided to change the SQL query and use donisback's suggestion (using MERGE); we explained the plan for teh new query and here is the results:
    SQL> explain plan for MERGE INTO temp_person t
      2  USING (SELECT fst_name ,p_id,ed_id
      3  FROM  ext_person) ext
      4  ON (ext.p_id=t.person_id AND ext.ed_id=t.district_id)
      5  WHEN MATCHED THEN
      6  UPDATE set t.first_name=ext.fst_name;
    Explained.
    SQL> @?/rdbms/admin/utlxpls.sql
    PLAN_TABLE_OUTPUT
    Plan hash value: 2192307910
    | Id  | Operation            | Name         | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | MERGE STATEMENT      |              | 92307 |    14M|       |  1417   (1)| 00:00:17 |
    |   1 |  MERGE               | TEMP_PERSON  |       |       |       |            |          |
    |   2 |   VIEW               |              |       |       |       |            |          |
    |*  3 |    HASH JOIN         |              | 92307 |    20M|  6384K|  1417   (1)| 00:00:17 |
    |   4 |     TABLE ACCESS FULL| TEMP_PERSON  | 93383 |  5289K|       |   192   (2)| 00:00:03 |
    |   5 |     TABLE ACCESS FULL| EXT_PERSON   | 92307 |    15M|       |    85   (2)| 00:00:02 |
    Predicate Information (identified by operation id):
       3 - access("P_ID"="T"."PERSON_ID" AND "ED_ID"="T"."DISTRICT_ID")
    Note
       - dynamic sampling used for this statement (level=2)
    21 rows selected.As you can see, the update now takes 00:00:17 to run (need to say more?) :)
    Thank you all for your ideas that helped us get to the solution.
    Much appreciated.
    Thanks

  • ABAP select statements takes too long

    Hi,
    I have a select statement as shown below.
    SELECT * FROM BSEG INTO TABLE ITAB_BSEG
                         WHERE  BUKRS = CO_CODE
                         AND    BELNR IN W_DOCNO
                         AND    GJAHR = THISYEAR
                         AND    AUGBL NE SPACE.
    This select statement runs fine in all of R/3 systems except for 1. The problem that is shown with this particular system is that the query takes very long ( up to an hour for if W_DOCNO consists of 5 entries). Sometimes, before the query can complete, an ABAP runtime error is encountered as shown below:
    <b>Database error text........: "ORA-01555: snapshot too old: rollback segment   
    number 7 with name "PRS_5" too small?"                                       
    Internal call code.........: "[RSQL/FTCH/BSEG ]"                              
    Please check the entries in the system log (Transaction SM21).  </b> 
    Please help me on this issue. However, do not give me suggestions about selecting from a smaller table (bsik, bsak) as my situation does not permit it.
    I will reward points.

    dont use select * ....
    instead u declare ur itab with the required fields and then in select refer to the fields in the select .
    data : begin of itab,
             f1
             f2
             f3
             f4
             end of itab.
    select f1 f2 f3 f4 ..
         into table itab
    from bseg where ...
    . this improves the performance .
    select * is not advised .
    regards,
    vijay

  • Update statement time too long

    HI
    im doing this update statement using toad and its been an hour now and not finished ( its only 900 records)
    and when i try to update 20 records only it takes about 3min
    update IC_ITEM_MST set WHSE_ITEM_ID ='503' where ITEM_NO like 'PP%'
    thnx
    Edited by: george samaan on Dec 21, 2008 10:35 PM

    select * from v$locked_object
    gave me this
    XIDUSN XIDSLOT XIDSQN OBJECT_ID SESSION_ID ORACLE_USERNAME
    OS_USER_NAME PROCESS LOCKED_MODE
    11 15 10999 36834 97 APPS
    appltst2 897256 3
    10 47 347465 63200 14 APPS
    Administrator 3124:2324 2
    10 47 347465 63569 14 APPS
    Administrator 3124:2324 2
    10 47 347465 63867 14 APPS
    Administrator 3124:2324 3
    10 47 347465 64380 14 APPS
    Administrator 3124:2324 2
    10 47 347465 64447 14 APPS
    Administrator 3124:2324 2
    10 47 347465 64934 14 APPS
    XIDUSN XIDSLOT XIDSQN OBJECT_ID SESSION_ID ORACLE_USERNAME
    OS_USER_NAME PROCESS LOCKED_MODE
    Administrator 3124:2324 2
    10 47 347465 78678 14 APPS
    Administrator 3124:2324 3
    10 47 347465 79069 14 APPS
    Administrator 3124:2324 3
    10 47 347465 64026 14 APPS
    Administrator 3124:2324 3
    10 47 347465 93468 14 APPS
    Administrator 3124:2324 3
    10 47 347465 209903 14 APPS
    Administrator 3124:2324 3
    10 47 347465 80084 14 APPS
    Administrator 3124:2324 3
    XIDUSN XIDSLOT XIDSQN OBJECT_ID SESSION_ID ORACLE_USERNAME
    OS_USER_NAME PROCESS LOCKED_MODE
    0 0 0 36944 60 APPS
    appltst2 1572894 3
    14 rows selected.

  • Select statement takes very long to run with order by clause.

    Hi all,
    I have a select statement which when I run without the order by clause takes arround 2 minutes to run. But with the order by clause it goes on for ever. I am trying to access the database server through a network which is not too fast.
    The select statement is based on 9 views which are again based on some views. It also has inline views and outer joins. These views and inline views can not be done away with.
    When selected without the order by clause it gives 3215 records.
    Anything like 2 to 3 minutes will be Ok.
    Thanks.
    --Malay                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    The select statement is as follows :-
    SELECT f.system_name,
    a.signal_type,
    f.sys_signal_name,
    a.bus_desc,
    b.vl_ident,
    b.vl_name,
    b.src_mac,
    b.src_mac_addr,
    b.dest_mac,
    b.dest_mac_addr,
    b.network,
    bb.bufr_size_in_bytes,
    bb.bag_in_ms,
    bb.is_rma_used,
    bb.is_ic_used,
    bb.sub_vl_cnt,
    bb.skew_max_in_ns,
    cc.msg_name,
    c.src_ip,
    c.src_ip_addr,
    c.src_port,
    c.dest_ip,
    c.dest_ip_addr,
    c.dest_port,
    cc.rate_in_ms,
    cc.tx_mode,
    cc.protocol,
    cc.port_type,
    cc.msg_length_in_bytes,
    d.mnemonic,
    d.start_addr32,
    d.lsb,
    d.end_addr32,
    d.msb,
    d.format,
    d.init_value,
    d.fs_mnemonic,
    d.fs_afdx_data_id,
    d.digital_data_id,
    DECODE(
    d.digital_datatype,
    NULL, '',
    'UNUSED', '',
    api$util.concat_column_data(
    'api_'
    || d.digital_datatype,
    'digital_data_id',
    d.digital_data_id,
    bool.FALSE
    ) AS data_details,
    f.connection_id
    || '_'
    || a.digital_bus_id
    || '_'
    || b.afdx_vl_id
    || '_'
    || bb.afdx_output_id
    || '_'
    || c.afdx_frame_id
    || '_'
    || cc.afdx_msg_id
    || '_'
    || d.afdx_data_id AS KEY
    FROM api_afdx a,
    api_afdx_vl b,
    api_afdx_output bb,
    api_afdx_frame c,
    api_afdx_msg cc,
    api_afdx_data d,
    vf_signal e,
    (SELECT DISTINCT aa.signal_id,
    cc.system_name,
    bb.connection_id,
    bb.sys_signal_name
    FROM vf_nodes aa,
    vf_connections bb,
    vf_system cc
    WHERE aa.connection_id = bb.connection_id
    AND bb.system_id = cc.system_id) f
    WHERE e.signal_id = f.signal_id(+)
    AND e.digital_bus_id = a.digital_bus_id
                   AND a.digital_bus_id = bb.digital_bus_id(+)
    AND bb.afdx_output_id = b.afdx_output_id(+)
                   AND b.afdx_vl_id = c.afdx_vl_id(+)
    AND bb.afdx_output_id = cc.afdx_output_id(+)
    AND cc.afdx_msg_id = d.afdx_msg_id(+)
    ORDER BY f.system_name,
    a.signal_type,
    f.sys_signal_name,
    b.vl_name,
    cc.msg_name,
    d.start_addr32,
    d.lsb;
    Where api_afdx ,
    api_afdx_vl ,
    api_afdx_output ,
    api_afdx_frame ,
    api_afdx_msg ,
    api_afdx_data ,
    vf_signal ,
    vf_nodes ,
    vf_connections ,
    vf_system
    are all views.

  • Query takes too long to run

    I ran the following query:
    select
            q1.ISO_COUNTRY_CODE q1country
            ,q3.ISO_COUNTRY_CODE q3country
            ,q1.LANGUAGE_CODE q1lang
            ,q3.LANGUAGE_CODE q3lang
            ,q1.POSTAL_CODE pcode1
            ,q3.POSTAL_CODE pcode3
            ,case when q1.POSTAL_CODE=q3.POSTAL_CODE then 1 else 0 end as "check"
        from street3 q3
            inner join street1 q1 on q1.PERM_ID=q3.PERM_ID
        where
    nvl(upper(q1.ISO_COUNTRY_CODE),'tempnull')=nvl(upper(q3.ISO_COUNTRY_CODE),'tempnull')
            and nvl(upper(q1.LANGUAGE_CODE),'tempnull')=nvl(upper(q3.LANGUAGE_CODE),'tempnull')
         --and q1.POSTAL_CODE=q3.POSTAL_CODE
            and rownum<10
    ;Results were returned in less than a second:
    Q1COUNTRY,Q3COUNTRY,Q1LANG,Q3LANG,PCODE1,PCODE3,check
    USA,USA,ENG,ENG,49946,49946,1
    USA,USA,ENG,ENG,49946,49946,1
    USA,USA,ENG,ENG,49946,49946,1
    USA,USA,ENG,ENG,49946,49946,1
    USA,USA,ENG,ENG,49946,49946,1
    ... etc.
    When I uncomment the line and q1.POSTAL_CODE=q3.POSTAL_CODE in the WHERE clause, however, the query takes forever to return. This doesn't make sense to me since the postcodes are equal in most cases anyway.

    TKPROF is almost always gross overkill. Certainly overkill until one exhausts what can be done using an explain plan. You are correct that AUTOTRACE requires a special role, and also requires the DBA runl a script which far too many do not know how to do. So the answer is to provide, any time you are asking for tuning help, an explain plan report as no special privileges are required.
    You will find demos here:
    http://www.morganslibrary.org/library.html
    under Explain Plan
    Post the SQL, the report, and your full version number for help.

  • Select/Update taking far too long to run, how can I get it to go faster?

    Hello all,
    I am trying to do an update/select on a table that returns 16 million records. So far most of the time it takes forever to complete or never finishes. Initially I was trying to do it as one big select, but when that didnt work, i broke it down to creating a table with the "base" 16 million records, and am trying to fetch additional values for each of those records from the table i grabbed those records from. Doing a select got me no where, so I am trying to do an update of the tables with the values i find using a cursor. Even this does not seem to be working. Is there a way to do it with a batch/bulk update that would be faster? The code is as follows: (oracle 10g):
    DECLARE 
       CURSOR wr63993_cur IS
          SELECT   provider_id,
                   din_gp_pin,
                   orig_prescription_nbr,
                   adjudication_date
            FROM   WR63993_BASE
           WHERE   adjudication_date BETWEEN to_date('2009/07/01', 'yyyy/mm/dd') AND to_date('2009/07/31', 'yyyy/mm/dd');
       CURSOR date_cur (v_provider_id WR63993_BASE.provider_id%TYPE,
                        v_din_gp_pin WR63993_BASE.din_gp_pin%TYPE,
                        v_orig_prescription_nbr WR63993_BASE.orig_prescription_nbr%TYPE,
                        v_adjudication_date WR63993_BASE.adjudication_date%TYPE)
          IS
          SELECT   MIN(adjudication_date) min_date
            FROM   claim_history@posi
           WHERE   provider_id = v_provider_id
             AND   din_gp_pin = v_din_gp_pin
             AND   orig_prescription_nbr = v_orig_prescription_nbr
             AND   adjudication_date >= ADD_MONTHS(v_adjudication_date, - 24);
    BEGIN
       FOR wr63993_rec IN wr63993_cur LOOP
          FOR date_rec in date_cur(wr63993_rec.provider_id, wr63993_rec.din_gp_pin, wr63993_rec.orig_prescription_nbr, wr63993_rec.adjudication_date) LOOP
             UPDATE   WR63993_BASE
                SET   min_date = date_rec.min_date
              WHERE   provider_id = wr63993_rec.provider_id
                AND   din_gp_pin = wr63993_rec.din_gp_pin
                AND   orig_prescription_nbr = wr63993_rec.orig_prescription_nbr;
          END LOOP;
      END LOOP;
      COMMIT;
    END;
    /

    aaah. healthcare insurance :)
    The performance of these, as i'm sure you know, is tricky.
    Consider the following which could help you eliminate your cursors. Here, B.adjudication_date will be the same as "MIN(adjudication_date) min_date" from your query.
    I understand that this is typically outside of your control, but if it is at all possible, move all of the data to the same database so you don't need those distributed queries. Separate schemas is ok.
    Select
      stuff
    From Wr63993_Base A
    Inner Join Claim_History@Posi B On A.Provider_Id=B.Provider_Id And A.Din_Gp_Pin=B.Din_Gp_Pin And A.Orig_Nbr=B.Orig_Nbr
    --the next table will allow you to get *earlier* instances of the claim where the adjudication date was in past 24 months
    --we only want to see the row where there ARE NO EARLIER instances. So this LOJ will return null for that row.
    Left Outer Join Claim_History@Posi C On A.Provider_Id=C.Provider_Id And A.Din_Gp_Pin=C.Din_Gp_Pin And A.Orig_Nbr=C.Orig_Nbr
    and c.adjudication_date >= ADD_MONTHS(a.adjudication_date, - 24) and c.adjudication_date<b.adjudication_date
    Where  
      A.Adjudication_Date Between To_Date('2009/07/01', 'yyyy/mm/dd')
      And To_Date('2009/07/31', 'yyyy/mm/dd')
      And B.Adjudication_Date >= Add_Months(A.Adjudication_Date, - 24)
      and c.adjudication_date is null --only get the row where B is the earliest qualifying adjudication date.
    Dave

  • Hi plz help me here .. I update my macbook air running with Mac 10.8.5 to yosemite and it will take too long to shut down and when stars it will like its gonig update?

    Hi plz help me here .. I update my macbook air running with Mac 10.8.5 to yosemite and it will take too long to shut down and when stars it will like its gonig update?

    More information would be helpful.

  • Sometimes my computer takes too long to connect to new website. I am running a pretty powerful work program at same time, what is the best solution? Upgrading speed from cable network, is it a hard drive issue? do I need to "clean out" the computer?

    Many times my computer takes too long to connect to new website. I have wireless internet (time capsule) and I am running a pretty powerful real time financial work program at same time, what is the best solution? Upgrading speed from cable network? is it a hard drive issue? do I only need to "clean out" the computer? Or all of the above...not to computer saavy.  It is a Macbook Pro  osx 10.6.8 (late 2010).

    Almost certainly none of the above!  Try each of the following in this order:
    Select 'Reset Safari' from the Safari menu.
    Close down Safari;  move <home>/Library/Caches/com.apple.Safari/Cache.db to the trash; restart Safari.
    Change the DNS servers in your network settings to use the OpenDNS servers: 208.67.222.222 and 208.67.220.220
    Turn off DNS pre-fetching by entering the following command in Terminal and restarting Safari:
              defaults write com.apple.safari WebKitDNSPrefetchingEnabled -boolean false

  • After updating my iphone 5s to 7.1 ... the keyboard is crashing and it takes too long to respond, what is the solution? if there any link from which we can download the original 7.1 firmware for A1533 Version?

    After updating my iphone 5s to 7.1 ... the keyboard is crashing and it takes too long to respond, what is the solution? if there any link from which we can download the original 7.1 firmware for A1533 Version?

    Restoring the iPhone will reload its firmware.
    Plug the iPhone into (the current version of) iTunes on your computer.
    Let it sync.  Then choose "Restore" from the iPhone's summary page in iTunes.

  • Update statement takes long time - Why so ?

    Dear DBAs;
    Daily update statement takes 20 mins. But today update takes more time.
    What is the reason how to resolve ?
    Thanks in advance ..

    8f953842-815b-4d8c-833d-f2a3dd51e602 wrote:
    Dear DBAs;
    Daily update statement takes 20 mins. But today update takes more time.
    What is the reason how to resolve ?
    Thanks in advance ..
    More time? How much more?

  • Sql Query takes too long to enter into the first line

    Hi Friends,
      I am using SQLServer 2008. I am running the query for fetching the data from database. when i am running first time after executed the "DBCC FREEPROCCACHE" query for clear cache memory, it takes too long (7 to 9 second) to enter into first
    line of the stored procedure. After its enter into the first statement of the SP, its fetching the data within a second. I think there is no problem with Sqlquery.  Kindly let me know if you know the reason behind this.
    Sample Example:
    Create Sp Sp_Name
    as
     Begin
     print Getdate()
      Sql statements for fetching datas
     Print Getdate()
     End
    In the above example, there is no difference between first date and second date.
    Please help me to trouble shooting this problem.
    Thanks & Regards,
    Rajkumar.R

     i am running first time after executed the "DBCC FREEPROCCACHE" query for clear cache memory, it takes too long (7 to 9 second)
    Additional to Manoj: A
    DBCC FREEPROCCACHE clears the procedure cache, so all store procedure must be newly compilied on the first call.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • HT1386 copying files in itunes takes too long

    When I drag music files into the iPhone's playlist, the copying takes too long.  I am running 11 and have a 4

    Wait on the update to finish downloading and installing.
    If the device is in recovery mode there is really nothing that can be done besides restoring it.

  • Why finding replication stream matchpoint takes too long

    hi,
    I am using bdb je 5.0.58 HA(two nodes group,JVM 6G for each node).
    Sometimes, I found bdb node takes too long to restart(about 2 hours).
    When this occurs, I catch the process stack of bdb(jvm process) by jstack.
    After analyzing stack,I found "ReplicaFeederSyncup.findMatchpoint()" taking all the time.
    I want to know why this method takes so much time,and how can I avoid this bad case.
    Thanks.
    帖子经 liang_mic编辑过

    Liang,
    2 hours is indeed a huge amount of time for a node restart. It's hard be sure without doing more detailed analysis of your log as to what may be going wrong, but I do wonder if it is related to the problem you reported in outOfMemory error presents when cleaner occurs [#21786]. Perhaps the best approach is for me to describe in more detail what happens when a replicated node is connecting with a new master, which might give you more insight into what is happening in your case.
    The members of a BDB JE HA replication group share the same logical stream of replicated records, where each record is identified with a virtual log sequence number, or VLSN. In other words, the log record described by VLSN x on any node is the same data record, although it may be stored in a physically different place in the log of each node.
    When a replica in a group connects with a master, it must find a common point, the matchpoint, in that replication stream. There are different situations in which a replica may connect with a master. For example, it may have come up and just joined the group. Another case is when the replica is up already but a new master has been elected for the group. One way or another, the replica wants to find the most recent point in its log, which it has in common with the log of the master. Only certain kinds of log entries, tagged with timestamps, are eligible to be used for such a match, and usually, these are transaction commits and aborts.
    Now, in your previous forum posting, you reported an OOME because of a very large transaction, so this syncup issue at first seems like it might be related. Perhaps your replication nodes need to traverse a great many records, in an incomplete transaction, to find the match point. But the syncup code does not blindly traverse all records, it uses the vlsn index metadata to skip to the optimal locations. In this case, even if the last transaction was very long, and incomplete, it should know where the previous transaction end was, and find that location directly, without having to do a scan.
    As a possible related note, I did wonder if something was unusual about your vlsn index metadata. I did not explain this in outOfMemory error presents when cleaner occurs but I later calculated that the transaction which caused the OOME should only have contained 1500 records. I think that you said that you figured out that you were deleting about 15 million records, and you figured out that it was the vlsn index update transaction which was holding many locks. But because the vlsn index does not record every single record, it should only take about 1,500 metadata records in the vlsn index to cover 15 million application data records. It is still a bug in our code to update that many records in a single transaction, but the OOME was surprising, because 1,500 locks shouldn't be catastrophic.
    There are a number of ways to investigate this further.
    - You may want to try using a SyncupProgress listener described at http://docs.oracle.com/cd/E17277_02/html/java/com/sleepycat/je/rep/SyncupProgress.html to get more information on which part of the syncup process is taking a long time.
    - If that confirms that finding the matchpoint is the problem, we have an unadvertised utility, meant for debugging, to examine the vlsn index. The usage is as follows, and you would use the -dumpVLSN option, and run thsi on the replica node. But this would require our assistance to interpret the results. We would be looking for the records that mention where "sync" points are, and would correlate that to the replica's log, and that might give more information if this is indeed the problem, and why the vlsn index was not acting to optimize the search.
    $ java -jar build/lib/je.jar DbStreamVerify
    usage: java { com.sleepycat.je.rep.utilint.DbStreamVerify | -jar je-<version>.jar DbStreamVerify }
    -h <dir> # environment home directory
    -s <hex> # start file
    -e <hex> # end file
    -verifyStream # check that replication stream is ascending
    -dumpVLSN # scan log file for log entries that make up the VLSN index, don't run verify.
    -dumpRepGroup # scan log file for log entries that make up the rep group db, don't run verify.
    -i # show invisible. If true, print invisible entries when running verify mode.
    -v # verbose

Maybe you are looking for

  • Applet very slow and shows no activity, but its running

    I have a new applet for the users, but I am reluctant to implement until I get some others opinions. It is very slow (30 - 40 seconds) Before it outputs a screen with about 20 lines, it reads 90 different html files. It looks at the forth rec of each

  • Itunes on iphone won't let me log in with correct password

    I have been all over the forums trying every options I have found. But when I go to update my apps my iphone/itunes asks for my password again. I have double and triple checked my password and it is correct. It is logging me in to my cloud, to the ap

  • How to populate both key and text in drop down list in dialog prog screen

    Hi, Can anyone please advice how to display both key and text in the drop down list in dialog prog screen. I tried with below code. keys and texts are getting populated in values table but only text is appearing when click on drop down. need to displ

  • All I want is audio from a DVD!

    I have a few music DVD's, and all I want is to get the audio from them into my iPod. 1) I've seen the debate rage re. whether or not one SHOULD be able to copy DVD's (video and all), but no one ever definitively asked or answered, much less on this s

  • Cannot edit PDFs with Acrobat 9.5.4

    I have over the last year been receiving PDF files from a lawfirm in NY which have no security on them, yet I cannot edit them.  All edit fuctions are greyed out.  The solution thus far has been to edit them using PDF Converter Professional, but I wo