相关子查询的更新语句太慢

Update statement is too slow with Correlated subquery

我正在使用下面的更新语句,它太慢了(大约需要 10-12 秒)

UPDATE temp_final t
   SET name = (
        SELECT DISTINCT(nm.name)
          FROM table_name nm,
               temp_final fn
         WHERE nm.id       = fn.senid
           AND fn.senid    = t.senid
           AND fn.rowgroup = t.rowgroup
           AND fn.mid      = t.mid
           AND fn.sid      = t.sid
           AND fn.pid      = t.pid
           AND fn.reid     = t.reid
           AND fn.retype   = t.retype
        )
 WHERE t.reid   = n_reid
   AND t.retype = n_retype
   AND t.sid    = c_sid
   AND t.pid    = n_pid;    

temp_final table 的列未编入索引,因为此 table 包含大量数据更新。我认为,我无法将相关子查询转换为加入,因为它使用此查询的不同 clause.Plan 给出以下结果:

OPERATION                              OBJECT        CARDINALITY     COST
- UPDATE STATEMENT                                       1925        337046      
  - UPDATE                             temp_final 
    -TABLE ACCESS(FULL)                temp_final        1925        171
      - Filter Predicates
        - AND
          -T.SID='123'
          -T.PID=21
          -T.REID=9
          -T.RETYPE=1
    -SORT(UNIQUE)                                         1          175
      - NESTED LOOPS                                      1          174 
         -TABLE ACCESS(BY INDEX ROWID)  TABLE_NAME        1           2
           -INDEX(UNIQUE SCAN)          NAME_PK           1           1  
             -ACCESS PREDICATES
               NM.ID=:B1
         -TABLE ACCESS(FULL)            temp_final        1           172
           - Filter Predicates
             - AND
               -fn.mid=:B1
               -fn.senid=:B2
               -fn.sid =:B3
               -fn.rowgroup =:B4
               -fn.pid=:B5
               -fn.reid=:B6
               -fn.retype=:B7
               -nm.id = fn.senid

Table temp_final 包含大约 8k 条记录,table table_name 包含大约 2 条 lac 记录

请告诉我如何提高此查询的性能?

此致

我不是很了解你的自加入。这个说法还不够吗:

UPDATE temp_final t
   SET name = (
        SELECT nm.name
          FROM table_name nm
         WHERE nm.id       = t.senid
        )
 WHERE t.reid   = n_reid
   AND t.retype = n_retype
   AND t.sid    = c_sid
   AND t.pid    = n_pid;