在ORACLE當中有兩個很常見的等待事件「SQL*Net message from client」與「SQL*Net message to client」,二者有點區別,下面整理這方面的資料以下:node
SQL*Net message from client 表示服務端等待着Cilent發來請求讓它處理,這時就會產生SQL*Net message from client等待事件。sql
而咱們把這種Wait叫作空閒事件(ildel event),並不表明真正的Loading.數據庫
SQL*Net message to client 這個等待事件發生在服務段向客戶端發送消息或數據的時候,通常意味着網絡瓶頸或不正確的TCP鏈接配置。緩存
固然它不能作爲對網絡延遲的準確評估或量化服務器
SQL*Net message from client網絡
"Generally SQL*Net message from client means Oracle is just waiting on some work to do. The SQL*Net message from client means that you have a session connected and Oracle is waiting for a command so it can do something.session
If you're thinking that SQL*Net message from client is the cause of a performance issue, there's likely another underlying issue such as the application connecting but not running any statements (which is not an Oracle issue but would appear to the end user as a performance problem), or you're looking in the wrong place for the source of the performance problem."oracle
關於SQL*Net message from client 這種等待事件,很好模擬,以下所示,會話68執行了一個SQL後,一直沒有向服務器端發送任何SQL語句,那麼在服務器端,會話68一直處於SQL*Net message from client等待事件app
會話68鏈接到數據庫後,執行完一個SQL後,再也不作任何操做。以下所示:tcp
SQL> show user;
USER 爲 "TEST"
SQL> select * from v$mystat where rownum=1;
SID STATISTIC# VALUE
---------- ---------- ----------
68 0 0
會話72中查看會話68的狀態,就會發現會話68處於SQL*Net message from client等待
SQL> show user;
USER is "SYS"
SQL> select * from v$mystat where rownum=1;
SID STATISTIC# VALUE
---------- ---------- ----------
72 0 0
SQL> select sid, seq#, event, wait_class,seconds_in_wait
2 from v$session_wait where sid=68;
SID SEQ# EVENT WAIT_CLASS SECONDS_IN_WAIT
---------- ---------- -------------------------------- ---------- ---------------
68 42 SQL*Net message from client Idle 314
可是若是此時在會話68裏面執行一個SQL語句,你會看到SECONDS_IN_WAIT就會清零從新開始計時。
另外還有一種特殊狀況,例如當客戶端遭遇網絡異常或應用程序奔潰、操做系統藍屏等等,那麼此時對應的會話也會可能遇到SQL*Net message from client空閒等待事件,固然絕大部分狀況下,這個等待事件是能夠忽略的。
SQL*Net message to client
The SQL*Net message to client may indicate a network-related issue that causes clients too long to get data from the database server. Thus, it can be a TCP issue, but it is not limited to that.
Common causes of a high SQL*Net message to client might include TCP/IP bottlenecks or TNS parameter issues:
High network latency: Check with netstat to ensure that your TCP/IP does not have bottlenecks.
Incorrect TNS parameters: Setting such as tcp.nodelay can impact the time for SQL message to client waits. See these tips on Oracle TNS network tuning .
The SQL*Net message to client Oracle metric indicates the server (foreground process) is sending a message to the client. Network bottlenecks are very common in distributed systems and those with high network traffic
「So, if you’re sending loads of data over a slow link or mis-configured TCP connection, the 「SQL*Net message to client」 wait time can be used as a low-confidence indicator of your SQL*Net throughput (in conjunction with 「bytes sent via SQL*Net to client」), but never a measure of network latency!」
SQL * Net message to client等待事件發生在當一個服務器進程已經發送數據或消息到客戶端並正等待回覆的時候.這個等待時間是等待從TCP(Transparent Network Substrate)等待響應的時間.這個等待事件一般被認爲是一個Network等待事件。SQL * Net message to client等待事件通常意味着網絡瓶頸或不正確的TCP鏈接配置。可是它不能作爲對網絡延遲的準確評估或量化。當服務端在發送大量數據時, 您能夠看到 "SQL * Net message to client" 等待事件所花的時間更長。這個發生在TCP發送緩衝區(TCP send buffer )已滿時, 所以TCP堆棧沒法接受更多的數據包。數據傳送將被阻塞, 直到遠程站點發送返回的 ACK 數據包表示它在 TCP 傳輸流( TCP transmission stream)中的哪些數據已經接收到了。
對於SQL * Net more data to client等待事件,ORACLE使用SDU(session data unit)會話數據單元將SDU緩存寫入到TCP套接字緩存中.若是數據比會話數據單元的初始大小大那麼數據須要被屢次的發送.若是有大量的數據被髮送而後在每批數據發送後這個會話將會等待'SQL * Net more data to client'等待事件.
ORACLE NET容許經過參數SDU(會話數據單元)和TDU(傳輸數據單元)來控制數據包的大小.它們分別控制會話層和傳輸層的緩存大小.TDU在數在ORACLE NET v8.0中已經被廢棄.
參考資料:
http://www.dba-oracle.com/m_sql_net_message_to_client.htm
http://blog.tanelpoder.com/2008/02/07/sqlnet-message-to-client-wait-gotcha/
http://www.dba-oracle.com/t_sql_net_message_network_throughput.htm