EXPLAIN PLAN of subquery in SET clause

From: Reinhard Kuhn <rek_at_cas-ps.com>
Date: 1995/06/28
Message-ID: <3ss5rl$59e_at_fred.cas-ps.com>#1/1


Hi,

I've been trying to optimize an update statement like   update foo set f1 = (<subquery>) where <condition> and found that the subquery can't be analyzed by the EXPLAIN PLAN statement.

Oracle support told me that:
"An UPDATE statement that invokes a subquery in the SET clause will  only have the tables(s) UPDATEd listed in the EXPLAIN PLAN output.  ... To see the path taken by the SET clause subquery, simply do an  EXPLAIN PLAN explicitly on the subquery itself."

However, this leaves three questions:

  • Why are subqueries in SET and WHERE clauses treated different?
  • Say I have a statement like update foo A set f1 = (select sum(f2) from foo B where A.f3 > B.f3) where <condition> Can I be sure that the path taken by the subquery as part of a statement is identical to the path taken by the subquery alone?
  • How can the output of the following SQL*Plus-script be explained?
    • snip -------------------------------- set echo off set heading off set feedback off

drop table t;
create table t (f1 number, f2 number(38));

truncate table plan_table;
explain plan for update t set f1=(select sum(f1) from t); select count(*) from plan_table;

truncate table plan_table;
explain plan for
 update t set f2=(select sum(f1) from t); select count(*) from plan_table;

----------------  snap ---------------------------------

BTW: I tried this on 7.1.3.3.6 on NT3.5 and
                     7.1.4.1.0 on HP-UX


Any comments or suggestions appreciated.

Thank you

-- 
    _/_/_/   _/_/_/ _/    _/  // Reinhard Kuhn             /  It can be      
   _/    _/ _/     _/  _/    //         (kuhn_at_cas-ps.com) /  done quickly,   
  _/_/_/   _/_/_/ _/_/      // CAS GmbH                  /  cheaply or well  
 _/  _/   _/     _/  _/    // Lemberger Strasse 14      /   - pick any two!  
_/   _/  _/_/_/ _/    _/  // 66955 Pirmasens, Germany  /   
                                   
Received on Wed Jun 28 1995 - 00:00:00 CEST

Original text of this message