【发布时间】:2013-01-29 17:46:38
【问题描述】:
我有这样的声明:
update new_table t2
set t2.creation_date_utc =
(select creation_date from old_table t1 where t2.id = t1.id)
where exists
(select 1 from old_table t1 where t2.id = t1.id);
根据解释计划的成本是 150959919。解释计划显示一些全表访问,总成本约为 3000,然后更新具有基本上无限的成本。如果运行,它确实似乎永远持续下去。
仅供参考,这些表每个的行数不超过 300k。
另外,这个查询。
select
(select creation_date from old_table t1 where t2.id = t1.id)
from new_table t2;
基本上立即完成。
这可能是什么原因?
【问题讨论】:
标签: sql oracle sql-update