DBAsupport.com Forums - Powered by vBulletin
Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Deleting records takes long time and unltimately servers hang

  1. #11
    Join Date
    Mar 2007
    Location
    Ft. Lauderdale, FL
    Posts
    3,555
    Quote Originally Posted by CoolGuyz View Post
    can we do something like "< trunc(sysdate - 2)'
    Code:
    select trunc(sysdate -2) from dual;
    Pablo (Paul) Berzukov

    Author of Understanding Database Administration available at amazon and other bookstores.

    Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.

  2. #12
    Join Date
    Apr 2009
    Posts
    6
    Quote Originally Posted by PAVB View Post
    So you are cascade deleting? I see, you are adding pieces of information one-at-a-time, some people would get crazy about that

    What else should we know?

    By the way, are you sure your predicate is no like: ... < trunc(sysdate - 2) ?
    Can we do something like < trunc(sysdate - 2) ???

  3. #13
    Join Date
    Apr 2009
    Posts
    6
    Quote Originally Posted by PAVB View Post
    Code:
    select trunc(sysdate -2) from dual;
    How can I change my query using "select trunc(sysdate -2) from dual" ???

  4. #14
    Join Date
    Nov 2002
    Location
    Mooresville, NC
    Posts
    349
    You can do it in a pl/sql procedure.
    Place the delete statement inside the loop. something like
    For i in reverse 3..100 Loop
    delete from table where date < sysdate-i;
    commit;
    end loop;
    http://www.perf-engg.com
    A performance engineering forum

  5. #15
    Join Date
    Sep 2002
    Location
    England
    Posts
    7,334
    Quote Originally Posted by malay_biswal View Post
    You can do it in a pl/sql procedure.
    Place the delete statement inside the loop. something like
    For i in reverse 3..100 Loop
    delete from table where date < sysdate-i;
    commit;
    end loop;
    welcome to ORA-1555

  6. #16
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Quote Originally Posted by CoolGuyz View Post
    How can I change my query using "select trunc(sysdate -2) from dual" ???
    So you are suggesting that it would be faster if you used a constant instead of sysdate-2 or trunc(sysdate-1). How do you know that sysdate-2 isn't a constant? It seems like a constant to me. That is constant as of the time it is being used. I don't see how your suggestion will change anything.

    You should go back and create explain plans for every table that gets deleted from when you delete from the main table. You might also try partitioning those tables by day as well. This way you would go around and drop and recreate partitions from all of your tables.

    For what you are doing 45 minutes might not be that bad, but dropping a bunch of partitions would be much faster, IMHO.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width