Results 1 to 3 of 3

Thread: Undo segment is getting full due to a procedure execution

  1. #1
    Junior Member
    Join Date
    Nov 2007
    Answers
    7

    Undo segment is getting full due to a procedure execution

    Hi all,

    We have a stored procedure which transfers data between two tables once in a month. oracle version is 10g

    Months data will be around 11Gb. But we have an UNDO segment of just 2Gb max.

    When ever the procedure executed the undo segment will become full and the procedure was still executinag even after 6 hours. Because of which we had to stop it by force.

    Please suggest me if there is a way of writing this procedure more efficiently.

    Please find the script below.

    --creates a table
    sql_stmt := 'create table '||V_TABLE_NAME||' tablespace test as ( select * from test1 where 1=2) ';

    execute immediate sql_stmt;

    -- copies the data to the above created table

    insert_query := 'insert into '||V_TABLE_NAME||' (select * from test2 where lastmodified >= (select trunc(add_months(sysdate,-4)) from dual) and lastmodified < (select trunc(add_months(sysdate,-3)) from dual))';

    execute immediate insert_query;

    -- deletes from the copied data from the source table

    delete_query := 'delete from test2 where lastmodified >= (select trunc(add_months(sysdate,-4)) from dual) and lastmodified < (select trunc(add_months(sysdate,-3)) from dual)';

    execute immediate delete_query;

    commit;

    Many thanks,
    Vinay


  2. #2
    Junior Member
    Join Date
    Nov 2007
    Answers
    7

    Re: Undo segment is getting full due to a procedure execution

    Can any body pls help.


    Quote Originally Posted by vinayhc View Post
    Hi all,

    We have a stored procedure which transfers data between two tables once in a month. oracle version is 10g

    Months data will be around 11Gb. But we have an UNDO segment of just 2Gb max.

    When ever the procedure executed the undo segment will become full and the procedure was still executinag even after 6 hours. Because of which we had to stop it by force.

    Please suggest me if there is a way of writing this procedure more efficiently.

    Please find the script below.

    --creates a table
    sql_stmt := 'create table '||V_TABLE_NAME||' tablespace test as ( select * from test1 where 1=2) ';

    execute immediate sql_stmt;

    -- copies the data to the above created table

    insert_query := 'insert into '||V_TABLE_NAME||' (select * from test2 where lastmodified >= (select trunc(add_months(sysdate,-4)) from dual) and lastmodified < (select trunc(add_months(sysdate,-3)) from dual))';

    execute immediate insert_query;

    -- deletes from the copied data from the source table

    delete_query := 'delete from test2 where lastmodified >= (select trunc(add_months(sysdate,-4)) from dual) and lastmodified < (select trunc(add_months(sysdate,-3)) from dual)';

    execute immediate delete_query;

    commit;

    Many thanks,
    Vinay



  3. #3
    Junior Member
    Join Date
    May 2008
    Answers
    1

    Re: Undo segment is getting full due to a procedure execution

    Hi Vinay,
    If you don't have a choice to increase the undo tablespace please try to break the insert operations into smilar chunks and try to commit. Otherwise you can go for the insert options with paralell hint and try. You are using stored procedure. If it's possible to run a script from OS level you can try out the copy command as well. But precisely speaking if the size of the undo is intact then you have to break your operation and commit it.

    Thanks & Regards
    Arunabha Datta

    Quote Originally Posted by vinayhc View Post
    Hi all,

    We have a stored procedure which transfers data between two tables once in a month. oracle version is 10g

    Months data will be around 11Gb. But we have an UNDO segment of just 2Gb max.

    When ever the procedure executed the undo segment will become full and the procedure was still executinag even after 6 hours. Because of which we had to stop it by force.

    Please suggest me if there is a way of writing this procedure more efficiently.

    Please find the script below.

    --creates a table
    sql_stmt := 'create table '||V_TABLE_NAME||' tablespace test as ( select * from test1 where 1=2) ';

    execute immediate sql_stmt;

    -- copies the data to the above created table

    insert_query := 'insert into '||V_TABLE_NAME||' (select * from test2 where lastmodified >= (select trunc(add_months(sysdate,-4)) from dual) and lastmodified < (select trunc(add_months(sysdate,-3)) from dual))';

    execute immediate insert_query;

    -- deletes from the copied data from the source table

    delete_query := 'delete from test2 where lastmodified >= (select trunc(add_months(sysdate,-4)) from dual) and lastmodified < (select trunc(add_months(sysdate,-3)) from dual)';

    execute immediate delete_query;

    commit;

    Many thanks,
    Vinay



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact