Solved

We need to update every row in a busy production OLTP database table that contains approximately 50 million rows

Posted on 2011-02-24
3
453 Views
Last Modified: 2012-05-11
We need to update every row in a busy production OLTP database table that contains approximately 50 million rows. Any suggestionson how we may approach this?
0
Comment
Question by:tesla764
3 Comments
 
LVL 10

Accepted Solution

by:
John Claes earned 500 total points
ID: 34972004
I see 2 different approches. that are not to heavy upon a busy environment.


1 make a cursor and flow for every records over the update and make sure you commit
(Is not my proposal)


2)
Make a Stored procedure
let this run the folowing script until it returns 0 changed records


Update TABLE
Set Field='Value'
where TABLEID in (SELECT TOP 100 TABLEID from TABLE (nolock) where Field<>'Value')



the nolock option will make sure that the values are taken directly from the database and not from the TRansactionSet - this is a fast Query and we can fastly execute.
Execution will take some time, but no User will notice it


0
 
LVL 15

Expert Comment

by:Aaron Shilo
ID: 34972237
hi

option 1:

set rowcount 1000

update mytable
set value = @value.
where value <> @value

option 2:
do this in small controlled chunks.
use the PK to control the rows you retrive and update every batch and move forward.
0
 

Author Comment

by:tesla764
ID: 34974122
Thanks.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question