実行計画取得時のSQL実行

(5.6)

drop table tab1;
create table tab1(col1 int);

insert into tab1 values(0);

analyze table tab1;

select * from tab1;

 

explain
update tab1 set col1 = 1 where col1 = 0;
→更新されない


(8.0.18)

drop table tab1;
create table tab1(col1 int);

insert into tab1 values(0);

analyze table tab1;

select * from tab1;


explain
update tab1 set col1 = 1 where col1 = 0;
→更新されない


explain analyze
update tab1 set col1 = 1 where col1 = 0;

→<not executable by iterator executor>と表示される

 

(12cR1)

drop table tab1 purge;
create table tab1(col1 int);

insert into tab1 values(0);
commit;

exec dbms_stats.gather_table_stats('TEST','TAB1');

select * from tab1;

 

--1.AUTOTRACEシステム変数

set autotrace on explain
update tab1 set col1 = 1 where col1 = 0;
→更新される

set autotrace on statistics
update tab1 set col1 = 1 where col1 = 0;
→更新される

set autotrace on
update tab1 set col1 = 1 where col1 = 0;
→更新される

set autotrace traceonly
update tab1 set col1 = 1 where col1 = 0;
set autotrace off
→更新される★


--2.PLAN TABLEの内容を表示
explain plan for
update tab1 set col1 = 1 where col1 = 0;

SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());

→更新されない

(9.4)

drop table tab1;
create table tab1(col1 int);

insert into tab1 values(0);

analyze tab1;

select * from tab1;

 

explain
update tab1 set col1 = 1 where col1 = 0;
→更新されない

explain analyze
update tab1 set col1 = 1 where col1 = 0;
→更新される★

 

 

(2014)

drop table tab1;
create table tab1(col1 int);

insert into tab1 values(0);


update statistics tab1;

select * from tab1;

 


set statistics profile on;
go
update tab1 set col1 = 1 where col1 = 0;
go
set statistics profile off;
go

→更新される


set statistics xml on;
go
update tab1 set col1 = 1 where col1 = 0;
go
set statistics xml off;
go

→更新される

 

set showplan_all on;
go
update tab1 set col1 = 1 where col1 = 0;
go
set showplan_all off;
go

→更新されない

set showplan_text on;
go
update tab1 set col1 = 1 where col1 = 0;
go
set showplan_text off;
go
→更新されない

set showplan_xml on;
go
update tab1 set col1 = 1 where col1 = 0;
go
set showplan_xml off;
go

→更新されない