Sql 从另一个表更新表时出现性能问题

Sql 从另一个表更新表时出现性能问题,sql,oracle,oracle-sqldeveloper,Sql,Oracle,Oracle Sqldeveloper,我试图用新数据更新旧客户数据,所以基本上我用新客户源表的firstname和lastname更新旧客户源表的firstname和lastname 我为新客户源的custid编制了索引,但我没有为旧客户源的custid编制索引的权限 要更新的记录总数约为50k,它们的查询运行时间超过30分钟 对于如何改进下面给定的Oracle查询,您有什么建议吗 update old_customer_source t1 set (t1.firstname, t1.lastname) = (

我试图用新数据更新旧客户数据,所以基本上我用新客户源表的firstname和lastname更新旧客户源表的firstname和lastname

我为新客户源的custid编制了索引,但我没有为旧客户源的custid编制索引的权限

要更新的记录总数约为50k,它们的查询运行时间超过30分钟

对于如何改进下面给定的Oracle查询,您有什么建议吗

update old_customer_source t1
   set   (t1.firstname, t1.lastname) = 
   (
    select  t2.firstname, t2.lastname
    from    new_customer_source t2
    where   t1.custid = t2.custid
   )
   where exists ( select 'x'
                from  new_customer_source t3
                where  t1.custid = t3.custid
              )
尝试使用合并

merge into old_customer_source t1
using (select t2.custid, t2.firstname, t2.lastname
         from  new_customer_source t2
      ) t2
 on (t1.custid = t2.custid)
when matched then
update set t1.firstname = t2.firstname, 
           t1.lastname = t2.lastname
;

没有人可以通过查看查询来调整查询。发布
执行计划
。并且总是提到数据库版本最多四位小数。
old\u customer\u source
有多大?假设
new\u customer\u source
有~50000行,因为这是更新的行数,安全吗?
旧客户源
或未索引外键上是否有触发器?两个源都有50000条记录。不,旧客户源没有FKs。没有旧客户源没有triggers@LalitKumarB,实际上并非如此,在SQL代码的特定结构中存在许多已知的性能问题,例如,在本例中,使用相关子查询。如果您读过关于数据库后端性能调优的任何内容(并且任何人都不应该查询没有读过performance tuning书籍的Datasse),那么您将知道要避免的结构。@HLGEM,在理论上,理论和实践是相同的,在实践中,它们是不同的。因此,很高兴看到执行计划,并做出切实可行的决定。而且它不需要执行查询。收集统计数据后,执行计划的准确率可以达到99%。所以,我要求提供执行计划,因为这是我在性能调优书籍中读到的。哦,顺便说一句,关于SQL调优,这都是关于基数的,你不能仅仅通过查看SQL就知道它。