The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > Web Programming, Web 2.0 and Mashups
.
google unix.com



Web Programming, Web 2.0 and Mashups Discuss Web Programming and Web Server Administration, including LAMP, Apache, MySQL, Flash, HTML, SEO, Mashups and other Web APIs and topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to delete duplicate rows based on last column reva Shell Programming and Scripting 16 09-01-2009 09:12 AM
column to rows based on another column... malcomex999 Shell Programming and Scripting 5 07-08-2009 06:28 AM
convert rows into column cdfd123 Shell Programming and Scripting 3 01-11-2008 12:54 PM
splitting a column into rows spindoctor UNIX for Dummies Questions & Answers 3 07-24-2007 03:25 PM
Factorize some rows in a column frebo UNIX for Dummies Questions & Answers 5 03-21-2006 06:41 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-30-2009
muay_tb muay_tb is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 30
Mysql question: Best way to update a column containing 8 million rows

Hi all,

I was wondering if anyone knew a good/safe way to update a single column in a table that could contain upto 8 million rows...

simple command like:

UPDATE set blah=foo where bar=XXX;

I will be running this on tables being written to and tables that have already been created.

---------- Post updated at 03:38 PM ---------- Previous update was at 06:54 AM ----------

no one have a way?

the only one i can think of is limiting the UPDATE and do it in batches?
  #2 (permalink)  
Old 09-30-2009
scottn scottn is offline Forum Advisor  
VIP Member
  
 

Join Date: Jun 2009
Location: Zürich, CH
Posts: 1,042
Hi.

Sorry, I'm not so familiar with mySQL, but as you didn't get an answer yet!

This is based on Oracle, but the same ideas should relate.

Firstly it's safe to update a table with however many rows. The worst that could happen is that the update fails and the uncommitted changes are rolled back.


You could:
  • split the updates in to smaller batches
  • add commit statements every few hundred / thousand statements
  • instruct your sql client to commit every few hundred / thousand statements
  • add more redo / undo logs or make your existing ones larger, or both
  • switch off logging on the table (alter table .. nologging if mySQL supports that) to reduce redo / undo (in most cases)
  • disable referential / unique constraint indexes (more for performance)

Last edited by scottn; 09-30-2009 at 06:48 PM..
  #3 (permalink)  
Old 10-01-2009
muay_tb muay_tb is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 30
Quote:
Originally Posted by scottn View Post
Hi.

Sorry, I'm not so familiar with mySQL, but as you didn't get an answer yet!

This is based on Oracle, but the same ideas should relate.

Firstly it's safe to update a table with however many rows. The worst that could happen is that the update fails and the uncommitted changes are rolled back.


You could:
  • split the updates in to smaller batches
  • add commit statements every few hundred / thousand statements
  • instruct your sql client to commit every few hundred / thousand statements
  • add more redo / undo logs or make your existing ones larger, or both
  • switch off logging on the table (alter table .. nologging if mySQL supports that) to reduce redo / undo (in most cases)
  • disable referential / unique constraint indexes (more for performance)
Many thanks Scottn

I think I am going down the road of creating a script to run in the background (as a cron task) and commit every X thousand records. I just didn't want to run the update all in one go as this would impact performance and increase logs made.
  #4 (permalink)  
Old 6 Days Ago
melina386 melina386 is offline
Registered User
  
 

Join Date: Nov 2009
Posts: 1
Mysql and a billion rows using innodb
read more
[b]Mysql and a billion rows using innodb - dslreports.com

Last edited by vbe; 6 Days Ago at 09:56 AM.. Reason: rm URL
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:23 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0