Quantcast
Channel: database – Tech ABC to XYZ
Viewing all articles
Browse latest Browse all 31

Optimize Mysql update query performance with

$
0
0

Optimize Mysql update query performance with

Asked By: mohit
Originally Asked On: 2014-01-02 09:50:26
Asked Via: stackoverflow

I have a table in which i need to add a column, The table has millions of record. For existing record i have to update the column value(which will be different for each record). Running individual update query will take lots of time. Is there a way where this can be achieved with minimum amount of locking time for the table.

He received 2 answers
without selecting any answers.

If the selected answer did not help you out, the other answers might!

All Answers For: Optimize Mysql update query performance with

Nachiket Kate’s answer to

Optimize Mysql update query performance with

in your case there can be two ways,

  1. if your additional column is a derived column (values can be derived from existing columns) then simple update query will be enough

  2. if its not derived one then write all the values in file (probably scripts) and import that file as new column in your table. (or export existing table and modify that file with new column values and then import)

in above two ways, import is faster with less amount of locking.
hope that helps :)

Joni’s answer to

Optimize Mysql update query performance with

When the hash value cannot be generated in the database, the only thing you can do is run individual updates. You may get some performance improvements by batching several updates into one transaction.

Of course, you should really check out the original question.

The post Optimize Mysql update query performance with appeared first on Tech ABC to XYZ.


Viewing all articles
Browse latest Browse all 31

Trending Articles