Delete Duplicates
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Delete Duplicates

  1. #1
    Join Date
    Mar 2001
    Posts
    52
    I have to delete 10,000 duplicates rows and it takes hours .I realy do not know what to do
    I wrote a proc that commits after 100 rows :

    exec del_proc ( ‘delete from my_table a where rowid>(select min(rowid) from my_table b where a.col1|a..col2||a.col3= b.col1|b..col2||b.col3’, 100)

    1.The table has one extent
    2.Rollback segment is large enough to handle the transaction (only this transaction in the db)
    3 Non unique index on my_table(col1,col2,col3)



    Thanks.

  2. #2
    Join Date
    Jul 2000
    Posts
    521
    why don't you create an index on those 3 columns and mention 3 different conditions in WHERE clause instead of concatination ?
    svk

  3. #3
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Do it in a single transaction (no commits inbetween), do it in SQL (no need forPL/SQL) and make the SQL statements so that Oracle can make use of your index:

    DELETE FROM my_table mt WHERE EXISTS
    (SELECT null FROM my_table
    WHERE col1 = mt.col1
    AND col2 = mt.col2
    AND col2 = mt.col2
    AND rowid < mt.rowid);

    This should fly in comparisson with your original delete, because the optimizer will use your index.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

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