I have a question on general database/sql server designing:
There is a table with 3 million rows that is being accessed 24×7. I need to update all the records in the table. Can you give me some methods to do this so that the user impact is minimized while I update my table?
Thanks in advance.
Normally you’d write a single update statement to update rows. But in your case you actually want to break it up.
http://www.sqlfiddle.com/#!3/c9c75/6
Is a working example of a common pattern. You don’t want a batch size of 2, maybe you want 100,000 or 25,000 – you’ll have to test on your system to determine the best balance between quick completion and low blocking.
We use patterns like this to update a user table about 10x your table size. With 100,000 chunks it takes about an hour. Performance depends on your hardware of course.