DB2 查看缓冲池真实大小

DB2中,修改缓冲池大小的命令有两个选项,默认的是IMMEDIATE,也就是立刻生效。 另一种是DEFERRED, 它只是在系统表中做了修改,实际上没有生效,需要重新激活数据库生效,也就是使用视图SYSCAT.BUFFERPOOLS查到的,并不一定是真实大小,那么如何查看缓冲池真实大小呢?

If the statement is executed as deferred, the following is true: Although the buffer pool definition is transactional and the changes to the buffer pool definition will be reflected in the catalog tables on commit, no changes to the actual buffer pool will take effect until the next time the database is started. The current attributes of the buffer pool will exist until then, and there will not be any impact to the buffer pool in the interim. Tables created in table spaces of new database partition groups will use the default buffer pool. The statement is IMMEDIATE by default when that keyword applies.


>>-ALTER BUFFERPOOL--bufferpool-name---------------------------->


     .-IMMEDIATE-.                                                                                        
>--+-+-----------+--+-------------------------------------+--SIZE--+-number-of-pages----------------+-+-><
   | '-DEFERRED--'  '-DBPARTITIONNUM--db-partition-number-'        '-+-----------------+--AUTOMATIC-' |   
   |                                                                 '-number-of-pages-'              |   
   +-ADD DATABASE PARTITION GROUP--db-partition-group-name--------------------------------------------+   
   +-NUMBLOCKPAGES--number-of-pages--+----------------------------+-----------------------------------+   
   |                                 '-BLOCKSIZE--number-of-pages-'                                   |   
   '-BLOCKSIZE--number-of-pages-----------------------------------------------------------------------'   



答案是使用MON_GET_BUFFERPOOL表函数。


参考测试如下:

$ db2 "create bufferpool bffpl1 immediate size 1000 PAGESIZE 4k"    
DB20000I  The SQL command completed successfully.


$ db2 "select substr(BPNAME, 1, 30) as BPNAME, BUFFERPOOLID, NPAGES, PAGESIZE from SYSCAT.BUFFERPOOLS"


BPNAME                         BUFFERPOOLID NPAGES      PAGESIZE   
------------------------------ ------------ ----------- -----------
IBMDEFAULTBP                              1          -2        4096
BFFPL1                                    2        1000        4096


  2 record(s) selected.


1.)
$ db2 "alter bufferpool bffpl1 size 1500"
DB20000I  The SQL command completed successfully.


$ db2 "select substr(BPNAME, 1, 30) as BPNAME, BUFFERPOOLID, NPAGES, PAGESIZE from SYSCAT.BUFFERPOOLS"


BPNAME                         BUFFERPOOLID NPAGES      PAGESIZE   
------------------------------ ------------ ----------- -----------
IBMDEFAULTBP                              1          -2        4096
BFFPL1                                    2        1500        4096


  2 record(s) selected.


$ db2 "select substr(BP_NAME, 1, 30) as BP_NAME, BP_CUR_BUFFSZ from table(MON_GET_BUFFERPOOL('BFFPL1',-1))"


BP_NAME                        BP_CUR_BUFFSZ       
------------------------------ --------------------
BFFPL1                                         1500


  1 record(s) selected.


采用默认的方式,发现系统表里发生了变化,实际大小也改变了。
  
2.)
$  db2 "alter bufferpool bffpl1 DEFERRED size 2000" 
DB20000I  The SQL command completed successfully.


$ db2 "select substr(BPNAME, 1, 30) as BPNAME, BUFFERPOOLID, NPAGES, PAGESIZE from SYSCAT.BUFFERPOOLS"


BPNAME                         BUFFERPOOLID NPAGES      PAGESIZE   
------------------------------ ------------ ----------- -----------
IBMDEFAULTBP                              1          -2        4096
BFFPL1                                    2        2000        4096


  2 record(s) selected.


$ db2 "select substr(BP_NAME, 1, 30) as BP_NAME, BP_CUR_BUFFSZ from table(MON_GET_BUFFERPOOL('BFFPL1',-1))"


BP_NAME                        BP_CUR_BUFFSZ       
------------------------------ --------------------
BFFPL1                                         1500


  1 record(s) selected.


采用了DEFERRED,虽然系统表发生了变化(1500->2000),但缓冲池实际大小没变(1500->1500),必须重新激活数据库才生效。


$ db2 terminate
DB20000I  The TERMINATE command completed successfully.


$ db2 connect to qsmiao


   Database Connection Information


 Database server        = DB2/AIX64 9.7.6
 SQL authorization ID   = E97Q6C
 Local database alias   = QSMIAO


$  db2 "select substr(BP_NAME, 1, 30) as BP_NAME, BP_CUR_BUFFSZ from table(MON_GET_BUFFERPOOL('BFFPL1',-1))"


BP_NAME                        BP_CUR_BUFFSZ       
------------------------------ --------------------
BFFPL1                                         2000


  1 record(s) selected.  

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值