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

在ORACLE当中有两个很常见的等待事件“SQL*Net message from client”与“SQL*Net message to client”,两者有点区别,下面整理这方面的资料如下:

 

 

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

                                而我们把这种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.

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."

 

 

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

 

 

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

 

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

时间: 2024-07-30 10:59:40

ORACLE等待事件:SQL*Net message from client & SQL*Net message to client的相关文章

Oracle 等待事件 一

以前一直想整理一下关于Oracle 的等待事件,总是没时间.现在觉得应该着手做了,其中的一些知识来自于自己的一点研究,如有错误,望大家指正..... 一 Oracle等待事件主要有两类事件: 1 空闲等待  空闲等待意味着Oracle正在等待某种动作的发生,实际上并不是因为繁忙而等待,而是因为没有事情做所以等待,如:smon timer,SMON进程的一些操作时每隔一段实际循环执行的,即使系统不忙,此事件也不立即发生,而是等待计时器达到一定的时间才执行,此时出现的smon timer 等待事件,

oracle等待事件7——事务上的等待事件

1.enq:TM-contention 执行DML期间,为防止对DML相关的对象进行修改,执行DML的进程必须对该表获得TM锁,若获得TM锁的过程发生争用,则等待enq:TM-contention事件. TM锁其用途十分明确,但是准确的概念及定义方面有容易混淆的一面.oracle的手册上关于锁的分类说明如下: DML锁:Date lock.执行DML时保护数据的锁.Row Lock(TX)保护特定行,Table Lock(TM)保护整个表,可以通过dba_kml_locks观察. DDL锁:Da

oracle等待事件12——网络上的等待事件

网络上的相关等待时间有如下几种: --SQL*NET message from / to client --SQL*NET more data from /to client --SQL*NET message from /to dblink --SQL*NET more data from / to dblink 这些事件大部分视为Idle(空闲)事件,所以分析性能问题时一般不予考虑.但某些情况下,这些事件对于分析性能下降原因可提供决定性线索.这些事件与性能问题相关的情况如下: 1)网络速度缓

oracle等待事件1——高速缓冲内cbc latch

恩..从今天起,木木同学要认真整理一下oracle中常见的等待事件,通过这部分的学习,希望自己能对oracle内部的结构能有一个更清晰的认识,有兴趣的童鞋一起来哇... 1.latch:cache buffers chains 从oracle 9i开始,以只读为目的的查询chains时,可以将cache buffers chains锁存器以shared模式共享,因此有助于减少争用. (我们需要注意,若能共享cache buffer chains 锁存器,理论上理论上不应该发生同时执行select

oracle等待事件11——重做缓冲区上的等待事件

1.latch:redo writing  , latch :redo allocation  ,latch:redo copy oracle 为了保护将重做记录复制到重做缓冲区的一连串过程,使用以下三个锁存器: 1)rodo writing 锁存器:为了占有重做缓冲区内的空间,向LGWR请求写入工作的进程需要获得redo writing锁存器.因为LGWR的写入工作不能同时执行,所以自然在整个实例上只有一个.redo writing锁存器是因为独立锁存器,所以可以通过v$latch_paren

oracle等待事件5——库高速缓存上的等待事件 中

3.library cache lock 和 library cache pin library cache lock 的定义:访问或修改库高速缓冲区的对象时,对库高速缓冲区句柄(handle)获得的锁,在获得library cache lock 的过程中,如果发生争用,则等待library cache lock事件. 通过library cache lock 事件的P1=handle address  P2=lock address  P3=mode*100+namespace,可以掌握对哪个

oracle等待事件3——高速缓冲内enq锁

6. enq:TC-contention 在手动执行检查点操作中,一部分需要获得TC锁(thread checkpointlock 或 tablespace checkpointlock )在获得TC锁过程中,若发生争用,则需要等待enq:TC-contention 事件.事实上获得TC锁的过程稍微复杂. 1) 服务器进程首先以X模式获得TC锁 2) 服务器进程将已获得的TC锁变更为SSX模式.同时,CKPT进程以SS模式获得该锁.CKPT获得锁后执行检查点操作. 3) 服务器欲重新以X模式获得

oracle等待事件9——I/O上的等待事件 上篇

1.db file scattered read oracle在执行全表扫描(FTS:full table scan)或全索引扫描(index full scan)时,为保障性能,尽量一次性读取多个块,这称为Multi Block I/O.每次执行multi block I/O,都会等待物理I/O结束,此时等待db file scattered read 事件.利用db file scattered read等待事件的P1=file#,P2=初始block#,P3=要读取的块数的信息,可以确认哪

oracle等待事件2——高速缓冲内等待事件

1.cache buffers lru chain 要想查看或修改工作组(LRU+LRUW)进程,始终要持有管理相应工作组的cache buffers lru chain 锁存器,若在此过程中发生争用,则要等待:latch:cache buffers lru chain 事件. 在下面两类情况下我们必须首先获得cache buffers lru chain锁存器: (1)进程想要读取还没有装载到内存上的块时,通过查询LRU列分配到所需空闲缓冲区,再次过程中需要cache buffers lru