Performance issue - insert records from db2 tables

I have a table say emp in oracle database and i have the emp table in db2 database. My job is to pull all the records (million records) from db2 table to oracle emp table. My insert statement is like below. I am connecting to the db2 database using dblink.
insert into emp
select * from emp_db2, dept_db2
where emp_db2.dno = dept_db2.dno
and dept_db2.dno = 10;
The statement is still running. How to improve the performance ?
please suggest.
thanks,
Vinodh

Vinodh2 wrote:
1.how much is your select query is taking? 1 day over . still running.
2.What is the row count from the query? 85632978 records
3.Whats your expected completion time? 30 minutes
I am not getting the explain plan because the query is still running.
do as below
SQL> set autotrace traceonly explain
SQL> select sysdate from dual;
Execution Plan
Plan hash value: 1388734953
| Id  | Operation      | Name | Rows     | Cost (%CPU)| Time     |
|   0 | SELECT STATEMENT |     |     1 |     2   (0)| 00:00:01 |
|   1 |  FAST DUAL      |     |     1 |     2   (0)| 00:00:01 |
-----------------------------------------------------------------

Similar Messages

  • Inserting records from internal table to database table

    Hi all,
    i want to insert records from internal table to zDatabase table, can u plz guide me which statement is better in performance to insert the records.
    1) insert one by one record from internal table
    loop at itab.
    insert ztable from wa.
    endloop.
    2) insert total records at a time
    INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or let me know if any other statement is there with high performance.
    i internal table contains nearly 40000 records.
    thanks.

    Hi,
    Insert the entire table at atime rather than a record so as to increase the performance.
    you can use INSERT <dbtabname> CLIENT SPECIFIED FROM TABLE itab.
    or
    MODIFY ZPRODUCT FROM TABLE GI_AFPO.
    Regards,
    Raj.

  • Retrive last inserted  record  from database table

    Hi,
    some body inserting a record into table 'A' through some procedure/java program.i want to retrive the last inserted record from database table.records are not stored in order.Can any body help me.

    In general, unless you are storing a timestamp as part of the row or you have some sort of auditing in place, Oracle has no idea what the "first" or "last" record in a table is. Nor does it track when a row was inserted.
    - If you have the archived logs from the point in time when the row was inserted, you could use LogMiner to find the timestamp
    - If the insert happened recently (i.e. within hours), you may be able to use flashback query to get the value
    - If you're on 10g or later and the table was built with ROWDEPENDENCIES and the insert happened in the last few days and you can deal with a granularity of a few seconds and you don't need 100% accuracy, you could get the ORA_ROWSCN of the row and convert that to a timestamp.
    If this is something you contemplate needing, you need to store the data in the row or set up some sort of auditing.
    Justin

  • Insert record from one table to another with help of cursor

    Plz help!!!
    tables are - 1. country( country_id pk, country_name, region_id)
    2. a( country_id , country_name, region_id)
    table a data are
    1 a 1
    2 b 2
    3 c 3
    null d 4
    5 e 5
    6 f 6
    7 g 7
    insert record from table a to country table with help of cursor, insert all not null records.
    this procedure does not give correct result
    create or replace
    procedure amit as
    cursor c1 is select * from a;
    rw a%rowtype;
    begin
    open c1;
    fetch c1 into rw;
    while(c1%found)
    loop
    insert into countries values(rw.country_id,rw.country_name,rw.region_id);
    commit;
    fetch c1 into rw;
    if rw.country_id is null then
    fetch c1 into rw;
    end if;
    end loop;
    close c1;
    exception
    when others then
    dbms_output.put_line('exception name= '||rw.country_name);
    end;

    bluefrog wrote:
    You don't need cursor at all;
    create or replace procedure amit as
    begin
    insert into countries (Country_ID, Country_Name, Region_ID)
    (select a.Country_ID
    ,a.Country_Name
    ,a.Region_ID
    from a
    dbms_output.put_line('Rows inserted : ' || sql%rowcount);
    commit;
    end;
    Bluefrog you missed where clause. :)
       insert into countries (Country_ID, Country_Name, Region_ID)
       (select a.Country_ID
              ,a.Country_Name
              ,a.Region_ID
        from a
        where country_id is not null
    );

  • Performance Issue: Retrieving records from Oracle Database

    While retrieving data from Oracle database we are facing performance issues.
    The query is returning 890 records and while displaying it on the jsp page, the page is taking almost 18 minutes for displaying records.
    I have observed that cpu usage is 100% while processing the request.
    Could any one advise what are the methods at DB end or Java end we can think of to avoid such issues.
    Thanks
    R.

    passion_for_java wrote:
    Will it make any difference if I select columns instead of ls.*
    possibly, especially if there's a lot or data being returned.
    Less data over the wire means a faster response,
    You may also want to look at your database, is that outer join really needed? Does it perform? Are your indexes good?
    A bad index (or a missing one) can kill query performance (we've seen performance of queries drop from seconds to hours when indexes got corrupted).
    A missing index can cause full table scans, which of course kill performance if the table is large.

  • How to get the last inserted record from a table ?

    :-) Hiee E'body
    I work on Oracle 8i and need to get the last
    record inserted in a table.
    I have tried using rownum and rowid pseudo-columns
    but that doesn't work.
    Can you please help me out ?
    :-) Have a nice time
    Vivek Kapoor.
    IT, Atul Ltd.,
    India.

    I'm not sure about 8i features.
    I assume here that you don't have 'Date-Time' stamp columns on the table which is the easiest way to determine the last inserted row in the table.
    If not try the following :-
    select address, piece, SQL_TEXT
    from V$SQLTEXT
    where upper(sql_text) like '%INSERT INTO TABLE_NAME%'
    Substiute the TABLE_NAME with the name of the actual table.
    Have fun.
    Regards,
    Shailender
    :-) Hiee E'body
    I work on Oracle 8i and need to get the last
    record inserted in a table.
    I have tried using rownum and rowid pseudo-columns
    but that doesn't work.
    Can you please help me out ?
    :-) Have a nice time
    Vivek Kapoor.
    IT, Atul Ltd.,
    India.

  • Insert records from one table to other table

    Hi,
    I want to insert all the records from table 1 which are not in table 2 into table2
    o/p
    insert into table2
    select * from table1
    where a.id!=b.id;
    Please let me know is there any way that I can populate the records

    insert
      into table2
      select  *
        from  table1
        where id not in (
                         select  id
                           from  table2
                        );SY.

  • Create Trigger to insert records from one table to another

    I created the below trigger to move data from one table to another after records have been inserted from another table to that table. What I need done is that each time records have been inserted into TEST_TBL, one of these actions codes should be implimented: U-update, N-insert, D-delete and inserted into TEST_TBL1. But each time I run the script, I get bunch of errors. Please see the script below: - Your help will be appreciated.
    create or replace
    trigger POWER_tr
    after update or insert or delete ON test_tbl
    for each row
    begin
    if updating then
    insert into test_tbl1
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, action_code, date_added
    VALUES
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, 'U', sysdate);
    ELSif INSERTING then
    insert insert into test_tbl1
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, action_code, date_added
    VALUES
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, 'N', sysdate);
    ELSIF deleting then
    insert into test_tbl1
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, action_code, date_added
    VALUES
    (idx, mke, ctl, ori, nam, sex, rac, pob, dob, hgt, 'D', sysdate);
    END IF;
    END POWER_tr;
    Thank you,
    Albert Zaza
    Edited by: azaza on Mar 1, 2009 4:14 PM

    Hello
    At the end of trigger show errors / and post what errors are you getting exactly?
    Here is a simple example for your reference, this will save old values in history table; you can replace it with new values if that's what do you want.
    CREATE OR REPLACE TRIGGER TRG_DU
       AFTER DELETE OR UPDATE
       ON EMPLOYEE    REFERENCING NEW AS New OLD AS Old
       FOR EACH ROW
    DECLARE
    BEGIN
       IF UPDATING
       THEN
          INSERT INTO employee_hist
            VALUES   ('UPDATE',
                      :OLD.empid,
                      :OLD.name,
                      :OLD.deptid);
       ELSIF DELETING
       THEN
          INSERT INTO employee_hist
            VALUES   ('UPDATE',
                      :OLD.empid,
                      :OLD.name,
                      :OLD.deptid);
       END IF;
    EXCEPTION
       WHEN OTHERS
       THEN
          -- Consider logging the error and then re-raise
          RAISE;
    END TRG_DU;
    /Regards
    Edited by: OrionNet on Mar 1, 2009 7:27 PM

  • Performance Issue When Read from Internal Table

    In my form, I have 6 windows which contain all the header information, which are kept in my gt_header internal table. Since all windows required data from the same internal table, reading the internal table at Initialization for once or, creating the LOOP at each window, which one will be a better choice in terms of performance?

    Hi,
    you cannot create 6 windows under loop.You can only have loop under a window only.
    So create a big window which covers whole area of 6 windows.Create templete under that and write only one loo with text in all those boxes of that templete.
    Regards,
    Rock.

  • Issue with fetching a record from IHPA table with PARNR value as condition

    Hi All,
    I am trying to fetch a particular record from IHPA table where i am giving the OBJNR number, PARVW and PARNR as customer no. , But I am not getting any record  but if i will give OBJNR and PARVW it will generate a record with having same PARNR value.
    Example :
    case 1st :-
    when i am passing following values in IHPA table,
    OBJNR  = IE000000000010070910
    PRAVW = BP                 
    PARNR  = 620000562   
    it is not generating any record  
    case 2nd:-
    But if i will pass  
    OBJNR  = IE000000000010070910
    PRAVW = BP
    it will generate a record?(one row) which will include PARNR as same 620000562 along with other value.
    Q1 -  Why it's not generating in case 1st,
    Q2 - How I will resolve this issue ? as i have to link some table as EQUI -
    IHPA -
    VCKUN
    VCNUM ?
          I have written a code for this to join :
         SELECT A~EQUNR
           B~PARVW
           C~CCNUM
           D~CCNUM
           FROM EQUI AS A JOIN IHPA AS B ON AOBJNR = BOBJNR
           INNER JOIN VCKUN AS C ON BPARNR = CKUNNR
           INNER JOIN VCNUM AS D ON CCCNUM = DCCNUM
           APPENDING CORRESPONDING FIELDS OF TABLE IT_OBSO
           WHERE A~EQUNR IN S_EQN.
                 AND PARVW  = 'BP'.
          But it is not generating any record but when i am commenting the PARVW i am getting the mixed record of PARVW as (BP,SP,SH)
    Let me know if any more clarification required.
    Highly appreciate your help
    Thanks & Regards
    Shaw

    Hi Santosh,
    Thanks for your quick response.
    But I am Sorry, I already checked with putting Zero before PARNR.
    The issue is still as it is.
    Thanks
    Shaw

  • Insert records from report program into R3 table

    Hi
    I wanted to insert records from report program into R3 table.
    here is my code
    data : itab type standard table of zemp initial size 10 with header line.
    itab-EMPNO = '012'.
    itab-ENAME = 'XXXX'.
    itab-JOB = 'XXXX'.
    APPEND itab.
    insert ztable from table itab.
    but i am getting the following error
    the type of the data base table and work area/internal table "ITAB" are no unicode-converible.
    how can I insert records from report program into R3 table
    should I have to write move corresponding
    pls guide
    thanks
    manian

    Hi,
    itab-EMPNO = '012'.
    itab-ENAME = 'XXXX'.
    itab-JOB = 'XXXX'.
    APPEND itab.
    insert ztable from table itab.
    Do one thing
    Data : itab type table of ztable with header line.
    itab-EMPNO = '012'.
    itab-ENAME = 'XXXX'.
    itab-JOB = 'XXXX'.
    APPEND itab.
    insert ztable from table itab.
    error will resolve, then try to make structure similar to ZTABLE

  • Inserting records from a txt file to a database table

    I would like to know how to insert records from a file (txt) to a database table through a java application?

    [BufferedReader |http://java.sun.com/javase/6/docs/api/java/io/BufferedReader.html] and PreparedStatement
    IO and JDBC

  • Inserting records in the table

    Hi All,
    I am working on a report where we are inserting huge numbers of records from an internal table to the ztable, I have been advised that rather than inserting all the records at one time we should divide the recods into small blocks may be let's say 100,000 of each block and try inserting the blocks in the ztable. So I was just wondering if anyone of you can help me with this how can I get this?
    my internal table is it_data_table and my ztable is z_data_table.
    Thanks,
    Rajeev

    Hi,
    Rather than inserting records from the workarea it is better if you use the inetrnal table for insertion. If youu have say 50025 records than it will hit the database that many times which definitely is a performance issue.If you have an internal table say 'it' and another internal table 'it_temp' with a similiar structure, you can try something like as follows
    loop at it.
      count = count + 1.
      it_temp = it.
      append it_temp.
      if count = 10000.
        insert ztable from table it_temp accepting duplicate keys.  "to avoid a dump if there are duplicates count = 0.
        refresh it_temp.
      endif.
    endloop.
    if it_temp is not initial.
      insert ztable from table it_temp accepting duplicate keys.
    endif.
    In the above code the loop will run the number of record times but, the insert statement will run only 50025/10000 times (i.e, 5 times). After the completion of the loop we need to add the remaining 25 records (because insert will work last inside the loop when 50000 records are reached), for that we will issue the insert statement after completion of the loop, after checking the it_temp table. So the total of 50025 records would be entered in a batch of 6 inserts rather than that many inserts if using just the workarea.
    I hope this does help you in your issue.
    Thanks and Regards,
    Sachin.

  • Using Crystal 2008 to insert records into a table

    Hi,
    We have a unique need to use Crystal to insert records into a table. We have managed to test a report that can write into a temporary table.  This is done by using sql command object  and uses  the following code :
    INSERT INTO TEMP_TABLE  (ORDERID)
    VALUES ({?orderid})   (-- where orderid a parameter).
    This test report asks for an order id and then inserts the record perfectly fine.
    Now moving on to the real report - This report basically prints orders in batches and we want to insert order id into a temporary table to ensure we don't print orders that were already printed. To do this we created a sub report "insert orders" that has the above insert command. The main report passes the orderid to subreport and the idea is that the subreport would insert each time an order is passed. So if main report printed 50 orders ids, the then it would do 50 inserts individually into the temp table. 
    This however is NOT working. The report runs fine but there is no insert.  Our hunch is that  Crystal is not committing after every order id is passed from the main report.  Not sure if we can set the AUTO COMMIT ON  as a default somewhere?
    Wondering if any one has attempted this or has any insights?
    Regards,
    Mohit.
    Environment is - Crystal 2008 and Oracle 11GR2, we are using Oracle drivers (and not odbc)

    Hmmm... I don't use Oracle but the syntax looks good...
    You've already tested it and I assume that you are using the same driver in the production report as you used in the test, so that shouldn't be an issue...
    how are you pulling the data? Is the final SELECT statement that pulls the report data in the same command as the INSERT script, or is the INSERT script in it's own command?
    The reason I ask... If you are trying to pass a multi-valued parameter to a command, it won't work. If you have the insert command as it's own command while the data is being pulled with linked tables or a separate command, it is possible that the report itself will execute as expected w/o passing a value to the insert script.
    If it's all in 1 command (as it should be), a bad parameter would fail in the final SELECT causing an error.
    Also... are rows null or empty string values being added to table when the report executes? This would be an indication that the command is being executed but isn't getting the parameter value.
    Jason

  • DELETE THE MATCHED RECORDS IN DB2 TABLE

    DELETE THE MATCHED RECORDS IN DB2 TABLE
    sql server table sqlserver_emp(c1,c2,c3,4)
    records:1 2 3 4
    DB2 table db2_emp(c1 key,c2,c3,c4)
    records:1 2 5 6 7 8
    Both tables having same structure
    Matched records : 1 2
    1.Delete the matched records in db2 table : 1 2 (without using truncate option for DB2 in Anywhere)
    2.Finally Load all records in sql server(Because duplicate records in db2 already removed so no duplicates occured)
    3.NEED final OUTPUT AS:db2 table: 5 6 7 8 1 2 3 4
    Note:
    1.DB2 truncate doesn't used
    2.STARING AREA: ORACLE
    3.SQLSERVER AND DB2 CLOSED ENVIRONMENT DOESN'T USED AS STAGING AREA.
    HOW MANY INTERFACES AND PROCEDURES SHOULD BE CREATE? WHAT ARE THEY?
    HOW TO REACH MY REQUIREMNT?
    Answer provider is more appricatable.
    Thanks in advance.
    Edited by: krishna on Nov 9, 2011 8:40 PM

    1st option
    See in this scenario you can use two interface and one procedure step.
    1st interface-->poricedure-->2nd interface
    1st interface will bring data to oracle staging-->then procedure will delete matched record from target using keys--->3rd interface will simple insert the the data in oracle staging.
    2nd option
    Insted of deleting the target matched records, you just update target matched record with latest records in your staging oracle.You can use IKM Merge
    Thanks

Maybe you are looking for

  • How to pass bind variable in report

    I'm trying to add tables and chart based of the value selected by the user using the filters. l_param_values := MGMT_IP_PARAM_VALUE_LIST(); l_param_values.extend(13); l_param_values(1) := MGMT_IP_PARAM_VALUE_RECORD ( 'oracle.sysman.eml.ip.render.elem

  • I am unable to print PDF files. Windows 7, Adobe Reader 11.0.06, Brother DCP 7065DN printer

    Receive messages "The document could not be printed." and "There are no pages selected to print." when in fact there are.

  • Changing country back to japan without credit card

    The apple id was in japan before, but i wanted to download some apps that can only be downloaded in the china app store. Now, i cant even go back to the japan itunes store and download or update anything because i have no credit card. Usually when i

  • How to send the PDF file to FAX will the nast table updates

    Hi all, How to send the PDF file to FAX. Will the nast table updates ( which fields updates ). Need is once fax is send for that delivery, again it should not fax again. Will the nast table helps to check the sent fax. Please give me sutable suggessi

  • How to Make a Checkbox editable in a JTable?

    I have a CustomModel inheriting from the AbstractTable Model. I make the isCellEditable( ) function in the CustomModel return true for all the columns(pl. see code snippet). One of the columns returns a Boolean value (checkbox in the table) and the r