开发者

MySQL mass UPDATE 40K rows with server resource friendly query

I have something like 40K rows and i must run update query like this:

UPDATE table1 
 SET column1='very long value 1...', column2='normal lenght value 1a'
WHERE pid ='123' and column3='ccc';

column1 is TEXT

column2 is Varchar(150)

...and i want to use mysql query what is more server resource friendly.

I want to use something like that:

UPDATE table1 
   CASE pid
    WHEN '123' THEN 'very long value 1...' 
    WHEN '124' THEN 'very long value 2...'  
    WHEN '543' THEN 'very long value 4...'  
    ...
    WHEN pid='34532' THEN 'very long value 5...'
    ELSE column1 
   END,
   column2= 
   CASE pid
    WHEN '123开发者_开发知识库' THEN 'normal lenght value 1a'
    WHEN '124' THEN 'normal lenght value 2a'
    WHEN '543' THEN 'normal lenght value 4a'
    ...
    WHEN pid='34532' THEN 'normal lenght value 5a'
    ELSE column2 
   END
WHERE pid IN ('123','124','543', ...,'34532') AND column3='ccc';

and my question is how many rows i can update in this way in one query?

Is there other server resource friendly method to update this 40K rows?


i think that it does not depend on the number of rows but the query size !

the size of one query its depend in the parameter

max_allowed_packet

http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_max_allowed_packet

to increase this u can look at :

http://dev.mysql.com/doc/refman/5.1/en/packet-too-large.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜