表A: 会话级临时表, 12条数据
表B: 分区表, 普通索引 id,t_date;1200万条数据,年分区,但是A表的时间区间跨年了;
SQL 1: for cur in (select id, beg_date, end_date from a) loopupdate a set a.money = (select sum(b.money)
from b
where b.id = cur.id
and b.t_date >= cur.beg_date
and b.t_date 复制代码执行时间 5s 左右;
SQL 2:update a set a.money = (select sum(b.money)
from b where b.id = a.id and b.t_date >= a.beg_date and b.t_date 复制代码执行时间 超过 60s 主动中断了...
想知道下为什么?
|