Amardeep Sidhu's Oracle blog

Little bit of fun with Oracle

Delete Delete Faster Faster ;)

with 3 comments

2-3 days ago, I came across a code, intended to make delete faster. Just have a look ;)

.
.
.
LOOP
SELECT COUNT (1)
INTO v_cnt
FROM table1
WHERE ROWNUM < 2;

IF v_cnt = 0
THEN
EXIT;
END IF;

DELETE FROM table1
WHERE ROWNUM < 1000;

COMMIT;
v_cnt := 0;
END LOOP;
.
.
.

Written by Sidhu

October 8th, 2009 at 8:53 pm

Posted in SQL

Tagged with ,

3 Responses to 'Delete Delete Faster Faster ;)'

Subscribe to comments with RSS or TrackBack to 'Delete Delete Faster Faster ;)'.

  1. What is the joke here?

    I am DB ignorant of the highest level :)

    Vaibhav

    10 Oct 09 at 7:58 am

  2. Hey man…

    Sorry for the prompt reply :P .

    The Joke is that he is committing inside the LOOP…which is a disaster in a database.

    Sidhu

    21 Dec 09 at 9:38 pm

  3. how many rows stored in this table?non-commit loop may cause large undo tablespace or ora-1555, i think we’d better choose a good recurring number and then commit.

    maclean

    9 Jun 10 at 10:07 pm

Leave a Reply

*
To prove you're a person (not a spam script), type the answer to the math equation shown in the picture. Click on the picture to hear an audio file of the equation.
Click to hear an audio file of the anti-spam equation