sql等待
❶ Oracle的sql語句中wait的含義
nowait:立即執行,如果另有會話正在修改該記錄會立即報告錯誤:ORA-00054: 資源正忙,要求指定 NOWAIT;如果不選擇nowait選項則會一直處理等待狀態。
wait [n]:等待n秒,如果另有會話正在修改該記錄會報告錯誤:ORA-30006: 資源已被佔用; 執行操作時出現 WAIT 超時
=>另外,還有一個skip locked。
skip locked:跳過已被別的會話鎖定的記錄
❷ SQL*Net break/reset to client 等待事件是什麼原因造成的
如果運行的代碼中包含某種可能的錯誤,且在調用中觸發了的話,伺服器端本地的服務進程有義務對遠程客戶端告知該信息,這個告知的過程中服務進程就處於SQL*Net break/reset to client等待中,直到客戶端收到問題信息為止。
大的查詢,表的不合理連接也會照成。
SQL> select * from v$mystat where rownum=1;
SID STATISTIC# VALUE
---------- ---------- ----------
135 0 1
SQL> insert into test05 values(1);
1 row inserted
SQL> commit;
Commit complete
SQL> alter session set events '10046 trace name context forever,level 8';
Session altered
查看trace文件
FETCH #1:c=0,e=204594,p=72,cr=129,cu=0,mis=0,r=1,dep=1,og=4,tim=6307709774
EXEC #2:c=0,e=263868,p=72,cr=130,cu=11,mis=0,r=0,dep=0,og=1,tim=6307739186
ERROR #2:err=1 tim=0
WAIT #2: nam='SQL*Net break/reset to client' ela= 3 driver id=1111838976 break?=1 p3=0 obj#=-1 tim=6307747970
WAIT #2: nam='SQL*Net break/reset to client' ela= 100 driver id=1111838976 break?=0 p3=0 obj#=-1 tim=6307748498
由於等待很短,需要查看v$session_wait_history視圖來追蹤,需要在別的session查看,不然可能查不到。
select event from v$session_wait_history where sid=135
SQL*Net message to client
SQL*Net break/reset to client
SQL*Net break/reset to client
SQL*Net message from client
SQL*Net message to client
SQL*Net message from client
SQL*Net message to client
SQL*Net message from client
SQL*Net message to client
SQL*Net message from client
SQL> create table test05(t int primary key);
Table created