Search notes:
Oracle execution plan operation OPTIMIZER STATISTICS GATHERING
create table tq84_A(col varchar2(1000));
We let Oracle choose a plan for inserting some random data into the table:
explain plan for
insert into tq84_A
select
dbms_random.string('a', 1000)
from
dual connect by level <= 10000;
Nothing special, so far:
select * from table(dbms_xplan.display(format=> 'basic'));
--
--
-- ------------------------------------------------
-- | Id | Operation | Name |
-- ------------------------------------------------
-- | 0 | INSERT STATEMENT | |
-- | 1 | LOAD TABLE CONVENTIONAL | TQ84_A |
-- | 2 | CONNECT BY WITHOUT FILTERING| |
-- | 3 | FAST DUAL | |
-- ------------------------------------------------
However, when using the
append
hint …
explain plan for
insert /*+ append */ into tq84_A
select
dbms_random.string('a', 1000)
from
dual connect by level <= 10000;
select * from table(dbms_xplan.display(format=> 'basic'));
--
-- ---------------------------------------------------
-- | Id | Operation | Name |
-- ---------------------------------------------------
-- | 0 | INSERT STATEMENT | |
-- | 1 | LOAD AS SELECT | TQ84_A |
-- | 2 | OPTIMIZER STATISTICS GATHERING | |
-- | 3 | CONNECT BY WITHOUT FILTERING | |
-- | 4 | FAST DUAL | |
-- ---------------------------------------------------
Execute the statement:
insert /*+ append */ into tq84_A
select
dbms_random.string('a', 1000)
from
dual connect by level <= 10000;
commit;
explain plan for
create table tq84_B as
select * from tq84_A;
A
CTAS also gathers online statistics:
select * from table(dbms_xplan.display(format=> 'basic'));
--
-- ---------------------------------------------------
-- | Id | Operation | Name |
-- ---------------------------------------------------
-- | 0 | CREATE TABLE STATEMENT | |
-- | 1 | LOAD AS SELECT | TQ84_B |
-- | 2 | OPTIMIZER STATISTICS GATHERING | |
-- | 3 | TABLE ACCESS FULL | TQ84_A |
-- ---------------------------------------------------
Cleaning up:
drop table tq84_A;
drop table tq84_B;
Parent row sources
I've encountered
OPTIMIZER STATISTICS GATHERING
as only row source for the following plan operations: