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
434 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now