Zunächst das Script:
-- SQL-Trace aktivieren EXEC DBMS_MONITOR.session_trace_enable(waits=>TRUE) -- Anlage einer ersten Testtabelle -- für ein Insert ohne Trigger drop table test1; create table test1 ( rn number , insert_date date); insert into test1 select rownum rn , sysdate insert_date from dual connect by level <= 1000000; -- Anlage einer zweiten Testtabelle -- für ein Insert mit Trigger drop table test2; create table test2 ( rn number , insert_date date); -- der Trigger leistet für das zweite Insert das, -- was das erste Insert ohne Hilfe schaffte: -- er ergänzt das Datum für die Spalte insert_date create or replace trigger test2_trigger before insert on test2 for each row begin select sysdate into :new.insert_date from dual; end test2_trigger; / insert into test2 (rn) select rownum rn from dual connect by level <= 1000000; EXEC DBMS_MONITOR.session_trace_disable
******************************************************************************** insert into test1 select rownum rn , sysdate insert_date from dual connect by level <= 1000000 call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 1.15 1.26 1 4748 26400 1000000 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 1.15 1.26 1 4748 26400 1000000 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 75 Rows Row Source Operation ------- --------------------------------------------------- 0 LOAD TABLE CONVENTIONAL (cr=0 pr=0 pw=0 time=0 us) 1 COUNT (cr=0 pr=0 pw=0 time=0 us) 1 CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=0 us) 1 FAST DUAL (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ Disk file operations I/O 2 0.00 0.00 db file sequential read 1 0.00 0.00 reliable message 1 0.00 0.00 enq: CR - block range reuse ckpt 1 0.00 0.00 log file switch completion 2 0.05 0.09 log file sync 1 0.02 0.02 SQL*Net message to client 1 0.00 0.00 SQL*Net message from client 1 0.00 0.00 ********************************************************************************
******************************************************************************** insert into test2 (rn) select rownum rn from dual connect by level <= 1000000 call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 1 0.00 0.00 0 0 0 0 Execute 1 96.72 96.41 1 4757 26387 1000000 Fetch 0 0.00 0.00 0 0 0 0 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 2 96.72 96.41 1 4757 26387 1000000 Misses in library cache during parse: 1 Misses in library cache during execute: 1 Optimizer mode: ALL_ROWS Parsing user id: 75 Rows Row Source Operation ------- --------------------------------------------------- 0 LOAD TABLE CONVENTIONAL (cr=0 pr=0 pw=0 time=0 us) 1 COUNT (cr=0 pr=0 pw=0 time=0 us) 1 CONNECT BY WITHOUT FILTERING (cr=0 pr=0 pw=0 time=0 us) 1 FAST DUAL (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1) Elapsed times include waiting on following events: Event waited on Times Max. Wait Total Waited ---------------------------------------- Waited ---------- ------------ db file sequential read 1 0.00 0.00 reliable message 1 0.00 0.00 enq: CR - block range reuse ckpt 1 0.00 0.00 SQL*Net message to client 1 0.00 0.00 SQL*Net message from client 1 0.00 0.00 ******************************************************************************** SQL ID: c749bc43qqfz3 Plan Hash: 1388734953 SELECT SYSDATE FROM DUAL call count cpu elapsed disk query current rows ------- ------ -------- ---------- ---------- ---------- ---------- ---------- Parse 2 0.00 0.00 0 0 0 0 Execute 999992 9.40 10.12 0 0 0 0 Fetch 999992 2.65 3.12 0 0 0 999992 ------- ------ -------- ---------- ---------- ---------- ---------- ---------- total 1999986 12.05 13.24 0 0 0 999992 Misses in library cache during parse: 0 Optimizer mode: ALL_ROWS Parsing user id: 75 (recursive depth: 1) Rows Row Source Operation ------- --------------------------------------------------- 1 FAST DUAL (cr=0 pr=0 pw=0 time=0 us cost=2 size=0 card=1) ********************************************************************************
select count(distinct insert_date) date_count from test1; DATE_COUNT ---------- 1 select count(distinct insert_date) date_count from test2; DATE_COUNT ---------- 111
Keine Kommentare:
Kommentar veröffentlichen