免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7798 | 回复: 9
打印 上一主题 下一主题

sp_monitorconfig 'procedure cache size'显示的结果大小如何计算的? [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-03-09 18:06 |只看该作者 |倒序浏览
结果如下:
1> sp_monitorconfig 'procedure cache size'
2> go
Usage information at date and time: Mar  9 2010  5:47PM.

Name                      Num_free    Num_active  Pct_act Max_Used         Num_Reuse
------------------------- ----------- ----------- ------- -----------         -----------
procedure cache size                0     4493610 100.00      4493894                   0

1> sp_configure 'procedure cache size'
2> go
Parameter Name                 Default     Memory Used Config Value         Run Value   Unit                 Type
------------------------------ ----------- ----------- ------------         ----------- -------------------- ----------
procedure cache size                  3271     1116040      512000              512000 memory pages(2k)     dynamic


我的procedure cache设置是512000*2k=1024M,这个值和monitor监控到的Max_Used=4493894如何比较?从moinitor显示的Num_free=0,是不是表示我的procedure cache size设置的不够大?

还有一个问题就是我的lock大小设为500,000,而sp_monitorconfig显示的结果如下:
1> sp_monitorconfig 'number of locks'
2> go
Usage information at date and time: Mar  9 2010  5:48PM.

Name                      Num_free    Num_active  Pct_act Max_Used         Num_Reuse
------------------------- ----------- ----------- ------- -----------         -----------
number of locks                498585        1415   0.28        95629                   0         
   
从上面是不是可以看出我设的lock已经足够大了,锁设置的足够大是不是就可以杜绝了死锁情况的产生?

论坛徽章:
1
2017金鸡报晓
日期:2017-01-10 15:19:56
2 [报告]
发表于 2010-03-10 09:55 |只看该作者
'number of locks' 是系统中同时拥有的锁的个数,但这个值的大小和是否导致死锁没有必然的关系。
关于死锁的产生,主要是由于应用使用和分配不当造成的

论坛徽章:
0
3 [报告]
发表于 2010-03-10 12:57 |只看该作者
1)看了下monitorconfig存储过程,把注释搬上来。
/*
** Syntax:
**
** sp_monitorconfig "configname" [, "result_tbl_name"] [, "full"] or
** sp_monitorconfig "all" [, "result_tbl_name"] [, "full"]
**
** This stored procedure provides statistics/monitor related information
** on a configuration parameter. This data could be extracted from
** monitor counters or from other places where statistics are maintained.
**
** For example, if the config name is 'open objects', then the monitor
** information is number of open objects, number of them free, percentage
** of open objects currently being used, etc. The actual information may be
** printed in stored procedure(s) invoked from here. Other config parameters
** can be added here.
**
** Note: The server collects these resource stats by default, however,
** you can turn off the activity by boot the server with trace flag 3631.
*/
      sp_monitorconfig打印出来的使用情况应该是从系统中实际统计得到的数据;sp_configure打印的是配置值。

2) 死锁不是dba人为可控的,这和ASE内部的锁机制实现相关。并行的transaction越多,DML操作越多,那产生死锁的概率就大了,这个和事务拿锁和放锁的时序有关。
可以将isolation level调低,譬如设置为0,这样就不会碰到死锁;但是代价是读到脏数据的可能性很大,有悖于业务的基本初衷。

论坛徽章:
0
4 [报告]
发表于 2010-03-10 14:28 |只看该作者
谢谢两位,不过还有第一个问题谁帮手回复一下?因为之前我查sybase的调优技术文档,不明天他们是怎么算出来的大小,其中一段如下:

You can also determine the current size of the procedure cache with sp_monitorconfig procedure cache size. This parameter describes the amount of space in the procedure cache is currently configured for and the most it has ever actually used. For example,the procedure cache in the following server is configured for 20,000 pages:
1> sp_configure "procedure cache size"
option_name config_value run_value
------------------------------ ------------ ---------
procedure cache size 3271 3271

However, when you run sp_montorconfig “procedure cache size”, you find that the most the procedure cache has ever used is 14241 pages, which means that you can lower the run value of the procedure cache, saving memory:
1> sp_monitorconfig "procedure cache size"
Usage information at date and time: Apr 22 2002 2:49PM.
Name num_free num_active pct_act Max_Used Reused
-------------- -------- ---------- ------- -------- ------
procedure cache 5878 14122 70.61 14241 No

论坛徽章:
6
水瓶座
日期:2014-06-04 03:34:37水瓶座
日期:2014-06-17 13:20:31数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00数据库技术版块每日发帖之星
日期:2016-07-17 06:20:00数据库技术版块每日发帖之星
日期:2016-08-01 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
5 [报告]
发表于 2010-03-10 14:52 |只看该作者
回复 4# sean_server


   
For example,the procedure cache in the following server is configured for 20,000 pages:
1> sp_configure "procedure cache size"
option_name config_value run_value
------------------------------ ------------ ---------
procedure cache size 3271 3271



这上面的数据不对吧,configured for 20,000 pages怎么会显示3271。很明显3271是默认配置的嘛!


However, when you run sp_montorconfig “procedure cache size”, you find that the most the procedure cache has ever used is 14241 pages, which means that you can lower the run value of the procedure cache, saving memory:

然而,当您用sp_monitorconfig存储过程来查看“procedure cache size”的参数值时,会发现曾经使用过的最大过程缓存是14241页。这就意味着:你可以通过减少参数procedure cache size的配置值来节省内存。

1> sp_monitorconfig "procedure cache size"
Usage information at date and time: Apr 22 2002 2:49PM.
Name num_free num_active pct_act Max_Used Reused
-------------- -------- ---------- ------- -------- ------
procedure cache 5878 14122 70.61 14241 No

num_free = 5878
num_active = 14122 这两者加起来= 20000,就是你先前配置的值 。

Max_Used  = 14241 表示曾经使用过的最大的过程缓存内存量。

目前的过程缓存内容使用率仅仅70.61%多。 你可以通过减少 procedure cache size 参数的值来减少内存消耗。

注意以上单位为:2K。

论坛徽章:
0
6 [报告]
发表于 2010-03-10 16:00 |只看该作者
那按照你说的理解不对啊?
参照我最上面提问的数据设置,我在sp_configure配置的procedure cache size=512000*2k=1024M,但是我在sp_monitorconfig中看的num_free=0,num_active= 4493610,这个又怎么解释呢?这两个值也不相等啊?

论坛徽章:
6
水瓶座
日期:2014-06-04 03:34:37水瓶座
日期:2014-06-17 13:20:31数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00数据库技术版块每日发帖之星
日期:2016-07-17 06:20:00数据库技术版块每日发帖之星
日期:2016-08-01 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
7 [报告]
发表于 2010-03-10 17:23 |只看该作者
不知道你看sp_monitorconfig的源码没有?最好自己看一下。
以前echoaix就在博客中介绍config_admin()这个系统函数的用法。

看sp_monitorconfig的源码,稀里糊涂的。通过config_admin计算的就不知道如何实现的了。
  1. /*
  2.         ** Get the run value for the config variable
  3.         */
  4.         select @config_runval = value
  5.         from   master.dbo.syscurconfigs
  6.         where  config = @confignum

  7.         /*
  8.         ** Retrieve info for the 4 counters. Pass flag 2 as the third
  9.         ** parameter of config_admin() to get the active value
  10.         */
  11.         select @num_active = config_admin(22, @confignum, 2, 0, @counter1, NULL)

  12.         /*
  13.         ** Pass flag 3 as the third parameter of config_admin() to get
  14.         ** the max value.
  15.         */
  16.         select @max_active = config_admin(22, @confignum, 3, 0, @counter2, NULL)

复制代码
个人总结出,config_admin()有6个参数。发现第一个参数有16或者22的情况。都是统计配置参数值的。
  1. 下面是我的研究总结:
  2. 1> select name,config_admin(16,config,1000,0,null,null) from sysconfigures where  name lik
  3. e '%number of open partitions%'
  4. 2> go
  5. name



  6. -----------------------------------------------------------------------------------------
  7. ------------------------------------------------------------------------------------------
  8. ----------------------------------------------------------------------------
  9.          -----------
  10. number of open partitions


  11.                  999


  12. config_admin应该是返回配置参数相关信息的函数。如:估计指定参数值的所耗内存,根据内存值估计可配置参数值大小。
  13. 还有其它未知??

  14. 如上面的例子:config_admin(16,config,1000,0,null,null)。第一个参数:16的意思是估计参数值所需配置内存大小,
  15. 或者根据内存显示可配置的参数大小。第二个参数为:参数数值,对应sysconfigures.config或syscurconfigs.config。
  16. 第三个和第四个参数是相关的。如果第四个配置为:1,则第三个参数数值表示内存值(以K为单位)。如果第四个参数配置为:0
  17. ,则第三个参数值表示配置参数值。第五、六个参数已知都配置为null。
复制代码

论坛徽章:
6
水瓶座
日期:2014-06-04 03:34:37水瓶座
日期:2014-06-17 13:20:31数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00数据库技术版块每日发帖之星
日期:2016-07-17 06:20:00数据库技术版块每日发帖之星
日期:2016-08-01 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
8 [报告]
发表于 2010-03-10 17:24 |只看该作者
个人感觉,玩这个没什么意思!

楼主没必要这么斤斤计较了~

论坛徽章:
0
9 [报告]
发表于 2010-03-10 19:13 |只看该作者
我的意思不是这样的,我看你的回复的大意是,procedure cache size=num_free+num_active,而实际的情况是我配置的procedure cache size是1024M大,但是在sp_monitorconfig中看的是num_free+num_active=0+4493610=4493610;那么这个4493610和我配置的1024M是相等的吗?

因为现在num_free=0,是不是表示我配的procedure cache size还不够?

论坛徽章:
6
水瓶座
日期:2014-06-04 03:34:37水瓶座
日期:2014-06-17 13:20:31数据库技术版块每日发帖之星
日期:2016-07-09 06:20:00数据库技术版块每日发帖之星
日期:2016-07-17 06:20:00数据库技术版块每日发帖之星
日期:2016-08-01 06:20:00数据库技术版块每日发帖之星
日期:2016-08-04 06:20:00
10 [报告]
发表于 2010-03-10 20:23 |只看该作者
回复 9# sean_server


    感觉这个值4493610 不准确。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP