连表更新
(1)update db_zxzhld_bak.t_zhld_zbajxx set d_larq =
(select larq from db_zxzhld_bak.cacheTable where db_zxzhld_bak.t_zhld_zbajxx.c_ajbh = db_zxzhld_bak.cacheTable.c_ajbh) where c_zblx in ('2001','2002');
更新757726条数据耗时3h。
(2)update db_zxzhld_bak.t_zhld_zbajxx t1 set d_larq = t.larq from db_zxzhld_bak.cacheTable t where t.c_ajbh = t1.c_ajbh AND t1.c_zblx in ('2001','2002');
修改过后的sql耗时6.5s
第一个sql查询其实是一个循环查询,特别耗时,类似于:
select c_bh,(select d_larq from t2) as larq from t1 ,嵌套循环。