您的位置:首页 > 数据库 > Oracle

ORACLE等待事件:SQL*Net message from client & SQL*Net message to client

2017-08-15 08:26 591 查看
在ORACLE当中有两个很常见的等待事件“SQL*Netmessagefromclient”与“SQL*Netmessagetoclient”,两者有点区别,下面整理这方面的资料如下:

SQL*Netmessagefromclient表示服务端等待着Cilent发来请求让它处理,这时就会产生SQL*Netmessagefromclient等待事件。

而我们把这种Wait叫做空闲事件(ildelevent),并不代表真正的Loading.

SQL*Netmessagetoclient这个等待事件发生在服务段向客户端发送消息或数据的时候,一般意味着网络瓶颈或不正确的TCP连接配置。

当然它不能做为对网络延迟的准确评估或量化

SQL*Netmessagefromclient

"GenerallySQL*NetmessagefromclientmeansOracleisjustwaitingonsomeworktodo.TheSQL*NetmessagefromclientmeansthatyouhaveasessionconnectedandOracleiswaitingforacommandsoitcandosomething.

Ifyou'rethinkingthatSQL*Netmessagefromclientisthecauseofaperformanceissue,there'slikelyanotherunderlyingissuesuchastheapplicationconnectingbutnotrunninganystatements(whichisnotanOracleissuebutwouldappeartotheenduserasaperformanceproblem),oryou'relookinginthewrongplaceforthesourceoftheperformanceproblem."

关于SQL*Netmessagefromclient这种等待事件,很好模拟,如下所示,会话68执行了一个SQL后,一直没有向服务器端发送任何SQL语句,那么在服务器端,会话68一直处于SQL*Netmessagefromclient等待事件

会话68连接到数据库后,执行完一个SQL后,不再做任何操作。如下所示:

SQL>showuser;
USER为"TEST"
SQL>select*fromv$mystatwhererownum=1;
SIDSTATISTIC#VALUE
------------------------------
6800


会话72中查看会话68的状态,就会发现会话68处于SQL*Netmessagefromclient等待

SQL>showuser;
USERis"SYS"
SQL>select*fromv$mystatwhererownum=1;
SIDSTATISTIC#VALUE
------------------------------
7200
SQL>selectsid,seq#,event,wait_class,seconds_in_wait
2fromv$session_waitwheresid=68;
SIDSEQ#EVENTWAIT_CLASSSECONDS_IN_WAIT
-----------------------------------------------------------------------------
6842SQL*NetmessagefromclientIdle314


但是如果此时在会话68里面执行一个SQL语句,你会看到SECONDS_IN_WAIT就会清零重新开始计时。









另外还有一种特殊情况,例如当客户端遭遇网络异常或应用程序奔溃、操作系统蓝屏等等,那么此时对应的会话也会可能遇到SQL*Netmessagefromclient空闲等待事件,当然绝大部分情况下,这个等待事件是可以忽略的。

SQL*Netmessagetoclient

TheSQL*Netmessagetoclientmayindicateanetwork-relatedissuethatcausesclientstoolongtogetdatafromthedatabaseserver.Thus,itcanbeaTCPissue,butitisnotlimitedtothat.

CommoncausesofahighSQL*NetmessagetoclientmightincludeTCP/IPbottlenecksorTNSparameterissues:

Highnetworklatency:CheckwithnetstattoensurethatyourTCP/IPdoesnothavebottlenecks.

IncorrectTNSparameters:Settingsuchastcp.nodelaycanimpactthetimeforSQLmessagetoclientwaits.SeethesetipsonOracleTNSnetworktuning.

TheSQL*NetmessagetoclientOraclemetricindicatestheserver(foregroundprocess)issendingamessagetotheclient.Networkbottlenecksareverycommonindistributedsystemsandthosewithhighnetworktraffic

“So,ifyou’resendingloadsofdataoveraslowlinkormis-configuredTCPconnection,the“SQL*Netmessagetoclient”waittimecanbeusedasalow-confidenceindicatorofyourSQL*Netthroughput(inconjunctionwith“bytessentviaSQL*Nettoclient”),butneverameasureofnetworklatency!”

SQL*Netmessagetoclient等待事件发生在当一个服务器进程已经发送数据或消息到客户端并正等待回复的时候.这个等待时间是等待从TCP(TransparentNetworkSubstrate)等待响应的时间.这个等待事件通常被认为是一个Network等待事件。SQL*Netmessagetoclient等待事件一般意味着网络瓶颈或不正确的TCP连接配置。但是它不能做为对网络延迟的准确评估或量化。当服务端在发送大量数据时,您可以看到"SQL*Netmessagetoclient"等待事件所花的时间更长。这个发生在TCP发送缓冲区(TCPsendbuffer)已满时,因此TCP堆栈无法接受更多的数据包。数据传送将被阻塞,直到远程站点发送返回的ACK数据包表示它在TCP传输流(TCPtransmissionstream)中的哪些数据已经接收到了。

对于SQL*Netmoredatatoclient等待事件,ORACLE使用SDU(sessiondataunit)会话数据单元将SDU缓存写入到TCP套接字缓存中.如果数据比会话数据单元的初始大小大那么数据需要被多次的发送.如果有大量的数据被发送然后在每批数据发送后这个会话将会等待'SQL*Netmoredatatoclient'等待事件.

ORACLENET允许通过参数SDU(会话数据单元)和TDU(传输数据单元)来控制数据包的大小.它们分别控制会话层和传输层的缓存大小.TDU在数在ORACLENETv8.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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: