postgre级联更新

常规写法

update t_table_copy a 
set content=(
  select content from t_table b where a.id = b.id
);

这写法,数据少了还行,数据多了,17w条数据几十分钟,呸

优化写法

update t_table_copy as p 
set content = a.content
from (
  select x.id,x.content from t_table x
) as a where p.id = a.id;

17w条数据11s

原文地址:https://www.cnblogs.com/xiaoliu66007/p/11052955.html