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

posted @ 2019-06-19 17:55  君子笑而不语  阅读(846)  评论(0编辑  收藏  举报