首页 数据库 mysql教程 SQL*Net网络相关的等待事件分析

SQL*Net网络相关的等待事件分析

Jun 07, 2016 pm 04:36 PM
net sql 事件 分析 相关 等待 网络

SQL*Net more data to client SQL*Net message to client SQL*Net more data from client SQL*Net message from client 群里的朋友给了一份awr报表,一般而言我们很少能看见SQL*Net这类等待事件成为top event中,而如果出现了我们还是要对这些等待事件有个清

<br> <img class="aligncenter size-full wp-image-2086 lazy" src="/static/imghw/default1.png" data-src="http://www.68idc.cn/help/uploads/allimg/150123/0T52C217-0.png" alt="" style="max-width:90%" title="1" style="max-width:90%">

SQL*Net more data to client
SQL*Net message to client
SQL*Net more data from client
SQL*Net message from client

群里的朋友给了一份awr报表,一般而言我们很少能看见SQL*Net这类等待事件成为top event中,而如果出现了我们还是要对这些等待事件有个清晰的认识,

先来看下SQL*Net more data to client和SQL*Net message to client等待事件
SQL> select name,parameter1,parameter2,parameter3,wait_class from v$event_name w
here name in ('SQL*Net message to client','SQL*Net more data to client');

NAME PARAMETER1 PARAMETER2 PARAMETER3 WAIT_C
LASS
---------------------------------------- ---------- ---------- ---------- ------
----
SQL*Net message to client driver id #bytes Network
SQL*Net more data to client driver id #bytes Network

Troubleshooting Waits for 'SQL*Net message to client' and 'SQL*Net more data to client' Events from a Performance Perspective (文档 ID 1404526.1)
A wait for 'SQL*Net message to client' occurs when a server process has sent data or messages to the client and it is waiting for a reply. The time spent waiting is time spent waiting for the response from the TCP (Transparent Network Substrate). This wait is usually considered an idle wait event, as the server process is waiting for something else to reply.

上面提到SQL*Net message to client一般发生在服务器端传输数据或者消耗到client端,等待client回复的等待,这个等待事件的消耗时间是等待tcp传输的相应。随着服务器在等待一些其他信息的回复,这个等待事件可以考虑为空闲的等待。

In terms of tuning, if individual wait times are high then the likelihood is that improvements cannot be made on the server, but elsewhere. If the total wait is high but individual waits are small then the waiting may be due to the way in which the data is being collected (i.e. too many round trips).

如果个别的等待比较高,那么调整服务器端将得不到相应的效果,可能在其他方面,如果总的等待比较高,但是个别的等待都较小,可能在由于数据被以往返的方式传输过多

For the 'SQL*Net more data to client' event wait, Oracle uses SDU (Session Data Unit) to write to the SDU buffer which is written to the TCP socket buffer. If data is larger than the the initial size of Session Data Unit then multiple chunks of data need to be sent. If there is more data to send then after each batch sent the session will wait on the 'SQL*Net more data to client' wait event.

对于SQL*Net more data to client等待事件, oracle使用sdu 来将tcp socket buffer写入到sdu buffer中。如果数据比session数据单元的初始化大小大,那么将发送多次。如果较多的数据发送,那么每批会话将看见SQL*Net more data to client等待事件。

对于诊断上述等待事件SQL*net more data to client和SQL*Net message to client最好的办法是跑一个10046 event

PARSING IN CURSOR #1 len=17 dep=0 uid=58 oct=3 lid=58 tim=26644922360 hv=1851853531 ad='5d591ab0'
select * from t01
END OF STMT
PARSE #1:c=0,e=46126,p=0,cr=0,cu=0,mis=1,r=0,dep=0,og=1,tim=26644922352
BINDS #1:
EXEC #1:c=0,e=9312,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=1,tim=26644933561
WAIT #1: nam='SQL*Net message to client' ela= 5 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=26644934130
FETCH #1:c=0,e=101,p=0,cr=4,cu=0,mis=0,r=1,dep=0,og=1,tim=26644934600
WAIT #1: nam='SQL*Net message from client' ela= 749 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=26644935726
WAIT #1: nam='SQL*Net message to client' ela= 2 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=26644936242
FETCH #1:c=0,e=425,p=0,cr=1,cu=0,mis=0,r=15,dep=0,og=1,tim=26644936646
WAIT #1: nam='SQL*Net message from client' ela= 57549 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=26644994574
WAIT #1: nam='SQL*Net message to client' ela= 2 driver id=1111838976 #bytes=1 p3=0 obj#=-1 tim=26644994966
。。。
STAT #1 id=1 cnt=50079 pid=0 pos=1 obj=51887 op='TABLE ACCESS FULL T01 (cr=3987 pr=0 pw=0 time=50172 us)'

看raw trace文件发现,这个sql语句一致性读为3987,其中物理读和物理写都是0,而消耗的时间则是50172us,接近50ms。

********************************************************************************

select * from t01

call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.04 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 3340 0.28 0.19 0 3987 0 50079
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 3342 0.28 0.25 0 3987 0 50079

Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 58

Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 3340 0.00 0.00
SQL*Net message from client 3339 0.11 118.36

Tkprof格式下raw trace: 这里总共取数据3340次,而也就伴随着3340次的SQL*Net message to client的等待,总的等待事件还为0.00,消耗的总时间是0.25秒,一致性读有3987。

Mos给出的参考标准:
Once the trace is obtained, you can TKProf it to see the timings and waits. Individual waits for 'SQL*Net message to client' are usually of very short duration (in this case the total wait is

If you notice unusually high waits for these events, for example as a top wait in statspack or AWR, then start the tuning process by tracing the process or the sql.

一般我们不必在意这个等待事件,但是如果出现在了awr或者statspack中,此时我们就需要对其跟踪进程。

1 SDU size
Remember that 'SQL*net message to client' is normally not a network issue, as the throughput is based on the TCP packet. The first session is sent the contents of the SDU buffer which is written to TCP buffer then the session waits for the 'SQL*net message to client' event. The wait is associated with the following factors:
? Oracle SDU size
? Amount of data returned to the client
One solution is to increase the SDU size. The following document can help with that:
Document 44694.1 SQL*Net Packet Sizes (SDU & TDU Parameters)

这里oracle优先推荐设置oracle SDU size,对于SDU个人不是太了解,这个属于oracle net方面的信息,这里大家可以参考上面的mos文章说明进行设置。

2 arraysize

If the application is using large amount of data, consider increasing the arraysize in the application. If small arraysize is used to fetch the data, then the query will use multiple fetch calls, each of these will wait for the 'SQL*net message to client' event. With a small arraysize and a large amount of data, the number of waits can become significant.

如果发送数据量较大,而又是一个较小的arraysize,此时一个查询就可能需要反复取数据,伴随着明显的SQL*Net message to client等待。

下面小鱼简单测试下
Set arraysize 150

然后查询设置10046 event跟踪:
select *
from
t01

call count cpu elapsed disk query current rows
------- ------ -------- ---------- ---------- ---------- ---------- ----------
Parse 1 0.00 0.00 0 0 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 335 0.10 0.08 0 1021 0 50079
------- ------ -------- ---------- ---------- ---------- ---------- ----------
total 337 0.10 0.08 0 1021 0 50079

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 58

Rows Row Source Operation
------- ---------------------------------------------------
50079 TABLE ACCESS FULL T01 (cr=1021 pr=0 pw=0 time=55 us)

Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
SQL*Net message to client 335 0.00 0.00
SQL*Net message from client 335 22.19 162.68
SQL*Net more data to client 895 0.00 0.00

这里将arraysize从默认的15设置为150后,此时一致性读从先前的3987降低为1021,fetch也已经从3340降低为335,而伴随着的SQL*Net message to client等待次数也有所降低了。

我们来看看T01表的数据分布,发现其中每个block大概存储着71 rows
SQL> select blocks,num_rows,round(num_rows/blocks) rows_per_block from user_tabl
es where table_name='T01';

BLOCKS NUM_ROWS ROWS_PER_BLOCK
---------- ---------- --------------
708 50079 71

当arraysize 15时,需要获取数据的次数是 50079/15= 3338.6次,而实际的获取次数3340基本相同,而当arraysize 150时,需要获取数据的次数则是50079/150=333.86次,而实际的获取次数是335次基本相同。

Mos有篇文章提到了arraysize行预取影响逻辑读和获取次数
Row Prefetching and its impact on logical reads and fetch calls (文档 ID 1419023.1)
ROW PREFETCHING
When an application fetches data from a database, it can do it row by row or by fetching numerous rows at the same time. Fetching numerous rows at a time is called row prefetching. Each time an application asks the driver to retrieve a row from the database, several rows are prefetched with it and stored in client-side memory. In this way,several subsequent requests do not have to execute database calls to fetch data. They can be served from the client-side memory. So, the number of round-trips to the database decreases proportionally to the number of prefetched rows

Oracle有一个行预取的概念存储,当应用程序请求从数据库获取数据时,获取的方式可以是逐行获取也可以是批次获取,获取数据后存储到了client的memory中,这样后续的查询就不必要再次访问数据库获取数据,而是从client的memory中获取,从而减少往返调用数据的次数。

关于我们常用的几种application关于arraysize的设置:
Sql*plus这个直接用set arraysize设置即可,默认arraysize 是15
OCI
With OCI, row prefetching is managed by two statement parameters: OCI_ATTR_PREFETCH_ROWS
and OCI_ATTR_PREFETCH_MEMORY.

JDBC
Row prefetching is enabled with the Oracle JDBC driver by default. You can change the default 10
number of fetched rows. Specify the property defaultRowPrefetch
when opening a connection to the database with either the class OracleDataSource or the class
OracleDriver

关于oci和jdbc小鱼并没有实际测试过,以后如果有时间在中间件上面也能进一步学习的话一定要进行实际的测试来验证

3 TCP
需要检查网络连接,比如交换机、局域网带宽负载等,这个需要有专门的网路工程师配合检查。

还有另外两个等待事件:SQL*Net more data from client和SQL*Net message from client

SQL*Net more data from client:
The server is reading more data from the client after it has already received some data. This typically occurs when the client is sending quite a bit of data to the server before it expects any response.

这里提到是oracle server已经接受了client发送的部分数据,这个等待经常发生在client发送大量数据给server端,但是server端还未收到任何响应。

Mos给出的减少等待次数和等待时间的参考:
1 time in the client process itself --客户端本身的时间
2 if you are expecting the client to be sending lots of data to the server –客户端传输数据到服务端的时间
3 time in the network between the client and the server. – 客户端到服务器端的网络传输时间

SQL*Net message from client
The Oracle shadow process (foreground process) is waiting for a message to arrive from the client process. This is generally considered as an "idle" event in that the Oracle shadow is idle waiting for the client process to tell it what to do. Time waiting in this state is attributable to the client process itself plus any network transport time.

SQL*Net message from client是个idle等待事件,这个发生在oracle server的后台进程等待client端发送的请求给server去处理,这个等待时间归于client自身加上网络传输
1 the client process waiting for input –客户端进程等待输入
2 time in the client process itself --客户端本身的时间
3 time in the network between the client and the server. – 客户端到服务器端的网络传输时间

我们来验证下这个SQL*Net message from client确实是个idle的等待:
SQL> select sid from v$session where sid=userenv('sid');

SID
----------
872

手动连接到数据库,查看这个连接会话的sid,这里我们没有做任何操作,换一个session来进行查询这个会话的等待事件:
SQL> select event,seconds_in_wait,state from v$session where sid=872;

EVENT SECONDS_IN_WAIT STATE
---------------------------------------- --------------- -------------------
SQL*Net message from client 285 WAITING

这里出现了所谓SQL*Net message from client等待,此时sid 872的会话没有做任何操作,只是在等待client发送请求给server process进行处理。

而上面朋友的awr报表中看出SQL*Net more data to client成为top event 2,那么根据小鱼上面文章的摘要主要为:
1 调整SDU参数
2 调整arraysize参数
3 分析网络是否存在瓶颈等

本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前 By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
4 周前 By 尊渡假赌尊渡假赌尊渡假赌

热工具

记事本++7.3.1

记事本++7.3.1

好用且免费的代码编辑器

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具

SublimeText3 Mac版

SublimeText3 Mac版

神级代码编辑软件(SublimeText3)

win10不能上网右下角显示地球怎么办 win10网络成地球无法上网的多种解决办法 win10不能上网右下角显示地球怎么办 win10网络成地球无法上网的多种解决办法 Feb 29, 2024 am 09:52 AM

这篇文章将介绍Win10系统网络显示地球标志但无法上网的解决方法。文章将提供详细的操作步骤,帮助读者解决Win10网络显示地球无法上网的问题。方法一:直接重启先检查一下网线是否没插好,宽带是否欠费,路由器或光猫可能会卡死,这时需重启路由器或光猫。假如当前电脑没有重要的事宜在操作,能直接重启电脑,大部分的小问题能通过重启电脑来快速解决。假如确定宽带没有欠费,网络正常,那便是另一回事。方法二:1、按【Win】键,或点击左下角的【开始菜单】,在打开的菜单项中,点击电源按钮上方的齿轮状图标,这个就是【设

Hibernate 框架中 HQL 和 SQL 的区别是什么? Hibernate 框架中 HQL 和 SQL 的区别是什么? Apr 17, 2024 pm 02:57 PM

HQL和SQL在Hibernate框架中进行比较:HQL(1.面向对象语法,2.数据库无关的查询,3.类型安全),而SQL直接操作数据库(1.与数据库无关的标准,2.可执行复杂查询和数据操作)。

Oracle SQL中除法运算的用法 Oracle SQL中除法运算的用法 Mar 10, 2024 pm 03:06 PM

《OracleSQL中除法运算的用法》在OracleSQL中,除法运算是常见的数学运算之一。在数据查询和处理过程中,除法运算可以帮助我们计算字段之间的比例或者得出特定数值的逻辑关系。本文将介绍OracleSQL中除法运算的用法,并提供具体的代码示例。一、OracleSQL中除法运算的两种方式在OracleSQL中,除法运算可以使用两种不同的方式进行

Oracle和DB2的SQL语法比较与区别 Oracle和DB2的SQL语法比较与区别 Mar 11, 2024 pm 12:09 PM

Oracle和DB2是两个常用的关系型数据库管理系统,它们都有自己独特的SQL语法和特点。本文将针对Oracle和DB2的SQL语法进行比较与区别,并提供具体的代码示例。数据库连接在Oracle中,使用以下语句连接数据库:CONNECTusername/password@database而在DB2中,连接数据库的语句如下:CONNECTTOdataba

网络连不上wifi怎么回事 网络连不上wifi怎么回事 Apr 03, 2024 pm 12:11 PM

1、检查wifi密码:确保自己输入的wifi密码是正确的,注意区分大小写。2、确认wifi是否正常工作:检查wifi路由器是否正常运行,可将其他设备连接至同一路由器,以确定问题是否出在设备上。3、重启设备和路由器:有时候,设备或路由器出现故障或网络问题,重启设备和路由器可能会解决问题。4、检查设备设置:确保设备无线功能处于开启状态,并且未将wifi功能禁用。

详解MyBatis动态SQL标签中的Set标签功能 详解MyBatis动态SQL标签中的Set标签功能 Feb 26, 2024 pm 07:48 PM

MyBatis动态SQL标签解读:Set标签用法详解MyBatis是一个优秀的持久层框架,它提供了丰富的动态SQL标签,可以灵活地构建数据库操作语句。其中,Set标签是用于生成UPDATE语句中SET子句的标签,在更新操作中非常常用。本文将详细解读MyBatis中Set标签的用法,以及通过具体的代码示例来演示其功能。什么是Set标签Set标签用于MyBati

Windows 11 文件夹共享指南:轻松分享你的文件和资料 Windows 11 文件夹共享指南:轻松分享你的文件和资料 Mar 13, 2024 am 11:49 AM

在日常生活和工作中,我们经常需要在不同设备之间共享文件和文件夹。Windows11系统提供了方便的内建文件夹共享功能,让我们可以轻松地在同一网络内安全地与他人分享所需内容,同时保护个人文件的隐私。这项功能使文件共享变得简单而高效,不必担心泄露私人信息。通过Windows11系统的文件夹共享功能,我们可以更加便捷地进行合作、交流和协作,提高工作效率和生活便利性。为了顺利配置共享文件夹,我们首先需要满足以下条件:所有(参与共享的)设备都连接到同一个网络。启用「网络发现」并配置好共享。知道目标设备中的

SQL出现5120错误怎么解决 SQL出现5120错误怎么解决 Mar 06, 2024 pm 04:33 PM

解决办法:1、检查登录用户是否具有足够的权限来访问或操作该数据库,确保该用户具有正确的权限;2、检查SQL Server服务的帐户是否具有访问指定文件或文件夹的权限,确保该帐户具有足够的权限来读取和写入该文件或文件夹;3、检查指定的数据库文件是否已被其他进程打开或锁定,尝试关闭或释放该文件,并重新运行查询;4、尝试以管理员身份运行Management Studio等等。

See all articles