oracle等待事件实验--log file

      测试插入数据单条循环提交和批量提交对日志等待事件的差异。

select event, total_waits, time_waited, average_wait
  from v$system_event
where event like '%log file%';
create table TX_LOCK_TAB
(
  A NUMBER,
  B CHAR(1),
  C VARCHAR2(20)
);
--单条循环提交:
declare
 i number;
begin
  for i in 1..2000000 loop
   insert into tx_lock_tab(a,b,c) values(i,'c','aaa');
   commit;
  end loop;
end;
--批量提交:
declare
 i number;
begin
  for i in 1..2000000 loop
   insert into tx_lock_tab(a,b,c) values(i,'c','aaa');
  end loop;
  commit;
end;

提交方式 event total_waits time_waited average_wait
  log file parallel write 728541 15953 0.02
批量提交 log file parallel write 729107 17418 0.02
    566 1465 0
循环提交 log file parallel write 1377283 26052 0.02
    648176 8634 0
  log file sequential read 266 169 0.63
批量提交 log file sequential read 290 200 0.69
    24 31 0.06
循环提交 log file sequential read 350 231 0.66
    60 31 -0.03
  log file single write 266 50 0.19
批量提交 log file single write 290 70 0.24
    24 20 0.05
循环提交 log file single write 350 75 0.21
    60 5 -0.03
  log file switch (checkpoint incomplete) 260 11880 45.69
批量提交 log file switch (checkpoint incomplete) 298 13728 46.07
    38 1848 0.38
循环提交 log file switch (checkpoint incomplete) 302 13962 46.23
    4 234 0.16
  log file switch completion 271 8606 31.76
批量提交 log file switch completion 291 9748 33.5
    20 1142 1.74
循环提交 log file switch completion 411 10422 25.36
    120 674 -8.14
  log file sync 796 554 0.7
批量提交 log file sync 805 559 0.69
    9 5 -0.01
循环提交 log file sync 843 576 0.68
    38 17 -0.01

         log file parallel write、log file sync区别:前台进程a通知LGWR要刷log buffer了,这时候a就开始等待log file sync,LGWR接到a的请求后开始等待OS把log buffer写回redo log,这时候LGWR就开始等待log file parallel write,OS写完了通知LGWR,中止log file parallel write等待,接着LGWR通知a,中止log file sync等待

         log file switch (checkpoint incomplete):日志切换时产生的检查点事需要等待的,这个日志文件所对应脏块全部写完后,检查点进程更新控制文件和数据头,然后这个检查点才能完成。

         log file sequential read:发生在对redo log信息进行读取时,比如在线redo的归档操作,ARCH进程需要读取redo log的信息是顺序写入的,所以在读取时也是按照顺序的方式读取。

         log file single write:发生在更新redo log文件的文件头时,当为日志组增加新的日志成员时或redo log的sequence号改变时,LGWR都会更新redo log 文件头信息。

         log file switch completion:等待日志切换完成。

你可能感兴趣的:(oracle等待事件实验--log file)