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
476 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

623 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