I would like to know if there is an automatic way or command to do a COMMIT after deleting X records (i.e., DELETE FROM CUSTOMERS AND COMMIT ON {number}?) If I have 1 million records to delete, what is the best way to delete and keep good perfomance? Thank you.

    Requires Free Membership to View

I don't think there's anything like what you're suggesting. But perhaps you don't need to DELETE. If you need to log the deletes (you know, in case something goes wrong and you need to roll back from the log), fine, but if you just want the table emptied, take a look in your database manual for the TRUNCATE TABLE command. It is extremely fast, because it removes all rows without logging. I don't know whether every database system has this command, but SQL Server, MySQL, and Oracle do.

This was first published in December 2005

Join the conversationComment

Share
Comments

    Results

    Contribute to the conversation

    All fields are required. Comments will appear at the bottom of the article.