I would like to perform an update statement impacting 10 million rows. It is a simple update like
UPDATE Table
SET ColumnX = 0;
I did notice that a simple SELECT
like
SELECT Column
FROM Table
takes about 34 seconds.
As it is a table used in production and the table is rather big (2,8 GB data, index 1,6 GB) I would like to estimate the runtime before executing the statement.
The update is performed on SQL Server 2008 R2.
Is there a possibility to obtain the estimated runtime?
There is no way to estimate this.
You ~could~ backup the database, restore it on similar hardware...and try that. But since no one will probably be hitting the restored-backup, even that is not an exact measurement.
If you can deal with having the updates occur....but without a transaction (aka, its ok for some rows to have the correct value for a few seconds...while the others do not), then I would invite the goldie locks approach.
Goldie Locks would be........not all the rows in one hit, but not row by row either.
Here is a pointer...Update TOP N ...
Maybe try 1,000 or 10,000 or something like that.
https://granadacoder.wordpress.com/2009/07/06/update-top-n-order-by-example/
........
Below is a modified example. I have 1,000 rows. I update 100 rows at a time, so it loops 10 times (10 x 100 = 1000)...to update the column.
It's a "goldie locks" trick..........I think this would serve you well on a real production db under load.