sql net message from|to client與sql execution count

wisdomone1發表於2013-05-20

----如下語句在某會話執行120次
update t_network set a=a+1;
update t_network set a=a+1;   
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;
update t_network set a=a+1;

--檢視某會話的事件
EVENT                                                            TOTAL_WAITS TIME_WAITED AVERAGE_WAIT
---------------------------------------------------------------- ----------- ----------- ------------
SQL*Net message to client                                                143           0            0
SQL*Net message from client                                              142        4748        33.44 --sql*net message from client猛增和to client
Disk file operations I/O                                                   3           0         0.08
log file sync                                                              1           0         0.07


--如果把上述的120次執行的sql用plsql實現又是如何呢
SQL> begin
  2  for i in 1..125 loop
  3   update t_network set a=a+1;
  4  commit;
  5  end loop;
  6  end;
  7  /

PL/SQL procedure successfully completed.

SQL> /
 
EVENT                                                            TOTAL_WAITS TIME_WAITED AVERAGE_WAIT
---------------------------------------------------------------- ----------- ----------- ------------
SQL*Net message to client                                                 15           0            0
SQL*Net message from client                                               14        1727       123.38 --總的等待次數及總的等待時間大為下降
Disk file operations I/O                                                   2           0         0.07
log file sync                                                              1           0         0.11
 
SQL>


小結:如果上述的sql*net message from/to client大量上升,表示sql執行次數很高,從這塊入手處理下問題
      這就是為何要用plsql封裝重複執行的sql原因,不然oracle與客戶端多次互動,會影響客戶的響應感覺與響應時間

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-761562/,如需轉載,請註明出處,否則將追究法律責任。

相關文章