MySQL全表更新调优

如何使整个表(测试的大小超过1亿个)尽快更新?剂量mysql有类似oracle的类似并行查询吗?

sql请求类似于:

update table test set col1 = DA(col1)

DA是某种变形算法功能。

这不是一次任务,因为我们需要定期将数据从生产数据库传输到测试数据库。在测试用户使用之前,一些敏感的数据列很容易变形(例如,“ ABC”到“!#@ !”)。

谢谢

nihaolizhiguo 回答:MySQL全表更新调优

更新表中的所有行非常耗时。原因与锁和日志记录有关。

进行大规模更新时,创建 new 表并重新加载旧表通常更快。像这样:

create table temp_test as
    select DA(col1) as col1,. . .   -- rest of the columns
    from test;

truncate table test;                 -- stash the old copy before doing this!

insert into test ( . . . )           -- list the columns here
    select . . .                     -- list the columns here
    from temp_test;
本文链接:https://www.f2er.com/3169358.html

大家都在问