您好,我是小DAI,专注于数据库管理员相关的技术问答,请问有什么可以帮您?

sp_monitorconfig

语法


sp_monitorconfig "<configname>"[, "<result_tbl_name>"][, "full"]

参数

<configname>

或者是 all,或者是要查询其监控信息的配置参数名的一部分。在“用法”部分中列出了有效的配置参数。指定 all 将显示服务器中所有索引、对象、数据库和辅助扫描描述符的描述符帮助信息。

“<result_tbl_name>”

(可选)为保存存储过程结果而创建的表的名称。如果为 <result_tabl_name> 传递了尚不存在的表名,sp_monitorconfig 将创建一个表来保存结果集。

"full"

为您指定的 configname 返回一组值。其值包括:

  • config_val – 报告配置值

  • system_val – 报告未配置任何值时的系统缺省值

  • total_val – 报告实际使用的值

    示例

    示例 1

    显示已打开的所有项:

    
    sp_monitorconfig "open"
    
    
    Configuration option is not unique.
    option_name                    config_value run_value  
    -----------------------------   ----------  ----------
    number of open databases                12           12
    number of open objects                 500          500
    curread change w/ open cursors           1            1
    open index hash spinlock ratio         100          100
    number of open indexes                 500          500
    open index spinlock ratio              100          100
    open object spinlock ratio             100          100
    number of open partitions              500          500
    

    示例 2

    显示所有配置的状态:

    
    sp_monitorconfig "all"
    

    </h2>
    Usage information at date and time: May  6 2010  4:32PM.
    Name                   Num_free Num_active Pct_act Max_Used Reuse_cnt Instance_Name
    --------------------   --------- --------- -------  ------- --------- -------------
    additional network memory  1358436  809440   37.34    825056        0           NULL
    audit queue size               100       0    0.00         0        0           NULL
    disk i/o structures            256       0    0.00        29        0           NULL
    heap memory per user          4096       0    0.00         0        0           NULL
    
    . . . 
    
    size of process object he     3000       0    0.00          0        0          NULL
    size of shared class heap     6144       0    0.00          0        0          NULL
    size of unilib cache        306216     816    0.27        816        0          NULL
    txn to pss ratio               400       0    0.00          0        0         NULL
    

    示例 3

    显示 61 个活动对象元数据描述符,其中 439 个是可用的。自 SAP ASE 服务器最后一次启动后在高峰期使用的最大值是 61:

    
    sp_monitorconfig "open objects"
    
    
    Usage information at date and time: Apr 22 2002  2:49PM.
    Name                   Num_free Num_active Pct_act Max_Used Reuse_cnt Instance_Name
    --------------------   --------- --------- -------  ------- --------- -------------
    number of open objects        439      61    12.20        61        0           NULL
    

    例如,您然后可以将该大小重新设置为 550,以容纳使用的最大元数据描述符的数目 439,外加 10% 的额外空间:

    
    sp_configure "number of open objects", 330
    

    示例 4

    显示索引元数据描述符的最大数目,该数目为 44:

    
    sp_monitorconfig "open indexes"
    
    
    Usage information at date and time: Apr 22 2002  2:49PM.
    Name                   Num_free Num_active Pct_act Max_Used Reuse_cnt Instance_Name
    --------------------   --------- --------- -------  ------- --------- -------------
    number of open indexes        556     44      7.33        44        0           NULL
    

    可以将该大小重新设置为 100,即最小可接受值:

    
    sp_configure "number of open indexes", 100
    

    示例 5

    将活动扫描描述符的数目显示为 30,尽管 SAP ASE 服务器被配置为使用 200 个这样的描述符。使用 number of aux scan descriptors 配置参数将该值重新设置为至少 32。较为保险的设置是 36,可以容纳 32 个扫描描述符,外加 10% 的额外空间:

    
    sp_monitorconfig "aux scan descriptors"
    
    
    Usage information at date and time: Apr 22 2002  2:49PM.
    
    Name                   Num_free Num_active Pct_act Max_Used Reuse_cnt Instance_Name
    --------------------   --------- --------- -------  ------- --------- -------------
    number of aux scan descri     170     30    15.00         32        0           NULL
    

    示例 6

    SAP ASE 服务器被配置用于 5 个打开的数据库,所有这些数据库都已用于当前会话:

    
    sp_monitorconfig "number of open databases"
    
    
    Name                   Num_free Num_active Pct_act Max_Used Reuse_cnt Instance_Name
    --------------------   --------- --------- -------  ------- --------- -------------
    number of open databses         0      5    100.00         5  Yes              NULL
    

    但是,如 Reuse_cnt 列所示,需要打开其它数据库。如果所有 5 个数据库都在使用中,将会导致错误,除非可以重新使用未在使用中的数据库描述符。为防止错误发生,应将 number of open databases 重新设置为更高的值。

    示例 7

    只有 10.2% 的事务描述符当前正在使用中。但是,自 SAP ASE 服务器最后一次启动后在高峰期使用的事务描述符的最大数目是 523:

    
    sp_monitorconfig "txn to pss ratio"
    
    
    Usage information at date and time: Apr 22 2002  2:49PM.
    Name                   Num_free Num_active Pct_act Max_Used Reuse_cnt Instance_Name
    --------------------   --------- --------- -------  ------- --------- -------------
    txn to pss ratio              784     80     10.20       523        0           NULL
    

    示例 8

    使用可选参数 <result_tbl_name> 可以创建用户表,并将 sp_monitorconfig 结果保存到此表中:

    
    create table sample_table
    (Name varchar(35),Config_val int, System_val int, Total_val int,
    Num_free int, Num_active int, Pct_act char(6), Max_used int,
    Num_Reuse int, Date varchar(30))
    
    
    create table sample_table
    (Name varchar(35),
    Config_val int,
    System_val int,
    Total_val int,
    Num_free int,
    Num_active int,
    Pct_act char(6),
    Max_Used int,
    Reuse_cnt int,
    Date varchar(30),
    Instance_Name varchar(35))
    

    创建的表名成为 sp_monitorconfig 的第二个参数。在 sample_table 中捕获 number of locks 和 number of alarms 的值:

    
    sp_monitorconfig "locks", sample_table
    sp_monitorconfig "number of alarms", sample_table
    

    显示在 sample_table 中捕获的值:

    
    select * from sample_table
    
    
    Name               Config_val System_val Total_val Num_free Num_active
    Pct_act Max_used Reuse_cnt   Date                Instance_Name
    ------------------- ----------- ---------- --------- --------- ----------
    ------- -------- ---------   ------------------- ------------------------
     number of locks         5000        684      5000     4915         85
    1.70        117         0    Aug 23 2006  6:53AM
     number of alarms             40       0        40       28         12
    30.00        13         0    Aug 23 2006  6:53AM
    

    保存到该表的结果集被累积,直到您删除或截断该表。

    > 注意

    如果 sample_table 在其它数据库中,则必须提供它的用引号引起来的全限定名。

    示例 9

    显示所有配置的 configure_value、system_value 和 run_value 列:

    
    sp_monitorconfig "all", null, "full"
    go
    
    
    Usage information at date and time: Mar 23 2004  5:15PM
    Name                    Configure Value  System Value  Run Value
    Num_free   Num_active  Pct_act  Max_Used  Reuse_cnt   Instance_Name
    ------------------------     ----------     ----------      -------
    ---------  ----------  -------  --------  ---------   -------------------
    additional network memory             0        2167876      2167876
      1358436      809440    37.34    825056          0                  NULL
    audit queue size                    100              0          100
          100           0     0.00         0          0                  NULL
    disk i/o structures                 256              0          256
          256           0     0.00        29          0                  NULL
    heap memory per user               4096            563         4096  
         4096           0     0.00         0          0                  NULL
    kernel resource memory             4096              0         4096
         3567         529    12.92       529          0                  NULL
    max cis remote connection             0            100          100
          100           0     0.00         0          0                  NULL
    . . .
    size of shared class heap          6144              0         6144
         6144           0     0.00         0          0                  NULL
    size of unilib cache            0307032         307032       306216
          816           0      .27       816          0                  NULL
    txn to pss ratio                     16              0           16
          400           0     0.00         0           0                 NULL
    

    用法

    使用 sp_monitorconfig 时,还存在一些其它注意事项:

  • 无论是否通过将 additional network memory 设置为正值进而将内存添加到池中,additional network memory 的输出都会报告全局网络内存池的运用统计信息。

  • 如果 max cis remote connections 配置参数具有 config_value,则 system_val 将报告一个零(0)值。

  • 如果使用比原始给定值小的值来重新配置资源,资源不会缩减,并且 Num_active 配置参数可以报告比 Total_val 大的数字。当 SAP ASE 服务器重新启动时,资源将缩减,并且数字正确报告。

  • sp_monitorconfig 显示与索引、对象和数据库的元数据描述符有关的高速缓存使用情况统计信息,例如当前由服务器使用的元数据描述符的数目。

  • sp_monitorconfig 还报告使用中的辅助扫描描述符的数目。在对表执行查询时扫描描述符管理表的单次扫描。

  • sp_monitorconfig 监控以下资源:

    - additional network memory

    - audit queue size

    - heap memory per user

    - max cis remote connection

    - max memory

    - max number network listeners

    - memory per worker process

    - max online engines

    - number of alarms

    - number of aux scan descriptors

    - number of devices

    - number of dtx participants

    - number of java sockets

    - number of large i/o buffers

    - number of locks

    - number of mailboxes

    - number of messages

    - number of open databases

    - number of open indexes

    - number of open objects

    - number of open partitions

    - number of remote connections

    - number of remote logins

    - number of remote sites

    - number of sort buffers

    - number of user connections

    - number of worker processes

    - partition groups

    - permission cache entries

    - procedure cache size

    - size of global fixed heap

    - size of process object heap

    - size of shared class heap

    - size of unilib cache

    - txn to pss ratio

  • number of sort buffers 配置参数不是服务器范围的设置;用于指定和限制每个排序的排序缓冲区数。但在服务器范围报告 sp_monitorconfig 计数器。如果正在进行多个排序操作,且每个操作所使用的排序缓冲区数量较大(最大值为 number of sort buffers),则排序缓冲区总数可超出 number of sort buffers 的值。

    服务器将排序缓冲区用于 update statistics、create index、order by、sort merge join、重新格式化(store_index)等排序操作。每个操作都可以使用一些排序缓冲区,但数量不得超过为 number of sort buffers 配置的值。如果运行多个具有排序操作的连接,则所使用的排序缓冲区数可能大于 number of sort buffers 的值。这是预期结果。但是,发出 sp_monitorconfig "number of sort buffers" 所显示的数量要高于已配置的值。

  • SAP ASE 使用 heap memory per user 的值作为配置全局堆池的源值。全局堆内存的值以此公式为基础:

    
    ("number of user connections" + "number of worker processes") X "heap memory per user"
    

    启动后,服务器会根据 heap memory per user 的值以及已配置用户连接数和工作进程数分配全局堆内存池,然后用户根据需要从全局堆内存池中获取堆内存。

    sp_monitorconfig "heap memory per user" 按用户显示全局池的使用信息。sp_monitorconfig "heap memory per user" 显示的 Num_active 和 Max_Used 计数器表示全局堆内存池中使用的总内存,预计这些值大于为 heap memory per user 配置的值。

  • sp_monitorconfig 输出中的列提供以下信息:

    - Num_free – 指定当前未使用的可用元数据或辅助扫描描述符的数目。

    - Num_active – 指定在高速缓存中安装的(即活动的)元数据或辅助扫描描述符的数目。

    - Pct_active – 指定存入高速缓存的或活动的元数据或辅助扫描描述符的百分比。

    - Max_Used – 指定自启动服务器后已在使用中的元数据或辅助扫描描述符的最大数目。

    - Reuse_cnt – 指定是否重新使用元数据描述符以容纳服务器中增加的索引、对象或数据库。返回值为 Yes、No 或 NA(用于不支持重用机制的配置参数,例如 aux scan descriptors 的数目)。

  • 以 Max_Used 列中的值为基础,确定描述符的适当数目;确保再增加约 10% 来作为最终设置。例如,如果使用的索引元数据描述符的最大数目是 142,则可以将 number of open indexes 配置参数设置为 157。

  • 如果 Reused 列指定为 Yes,则将该配置参数重新设置为更高的值。在描述符需被重新使用的情况下,可能会有性能问题,在有打开的数据库时尤需注意。打开的数据库中包含大量的元数据信息,这意味着若要填满一个打开的数据库,SAP ASE 服务器需要多次访问磁盘上的元数据;服务器可能还具有自旋锁争用问题。若要检查自旋锁争用情况,请使用系统过程 sp_sysmon。请参见《性能和调优系列:使用 sp_sysmon 监控 Adaptive Server》。若要确定索引、对象或数据库的当前数目,请使用 sp_countmetadata。

  • 若要获取精确的数据,请在正常的 SAP ASE 高峰期运行 sp_monitorconfig。您可以在高峰期运行 sp_monitorconfig 几次,以确保实际查找的就是使用的描述符的最大数目。

  • <result_tbl_name> 使用以下语法创建表:

    
    create table table_name(
        Name varchar(35), Num_free int,
        Num_active int, Pct_act char(6),
        Max_Used int, Reuse_cnt int,
        Date varchar(30))
    

    所有结果信息都保存在该表中,不返回任何标准输出。

  • 某些配置参数(例如 <number of sort buffers><txn to pss ratio>)依赖于配置的用户连接的数目,而其它配置参数(如 <max number of network listeners>)则依赖于引擎数。

  • 对于配置值 <permission cache entries>Num_freeNum_activePct_actMax_Used 的值是每个连接值的平均值,然而,Reuse_cnt 是服务器范围值。

  • sp_monitorconfig 的输出使用用户连接和联机引擎的数目来计算列 num_free、num_active、pct_act 和 max_used 的值。

  • 出于性能原因,对内部监控计数器的更新不使用同步方法进行。因此,负荷较重的多引擎 SAP ASE 服务器在 sp_monitorconfig 输出中报告的数目可能不完全精确。

  • 您可能会看到,空闲系统中的活动锁数大于 0。这些“活动”锁是保留的,供内部使用。