Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2737045
  • 博文数量: 423
  • 博客积分: 7770
  • 博客等级: 少将
  • 技术积分: 4766
  • 用 户 组: 普通用户
  • 注册时间: 2006-11-09 11:58
个人简介

Oracle/DB2/Postgresql/Mysql/Hadoop/Greenplum/Postgres-xl/Mongodb

文章分类

全部博文(423)

文章存档

2019年(3)

2018年(6)

2017年(27)

2016年(23)

2015年(30)

2014年(16)

2013年(31)

2012年(73)

2011年(45)

2010年(14)

2009年(30)

2008年(30)

2007年(63)

2006年(32)

分类: DB2/Informix

2016-01-18 13:52:22

DB2-9.7自动存储管理表空间收缩测试


1、查看表空间是否支持表空间启用可回收存储器


[db2inst2@localhost ~]$ db2 -tsvf showremin.sql 
select substr(TBSP_NAME,1,14),reclaimable_space_enabled from table (MON_GET_TABLESPACE(NULL,-1)) WHERE TBSP_NAME NOT  LIKE ('SYS%')


1              RECLAIMABLE_SPACE_ENABLED
-------------- -------------------------
TEMPSPACE1                             0
USERSPACE1                             1    --如果是 1表示支持


  2 条记录已选择。

[db2inst2@localhost ~]$
[db2inst2@localhost shell]$  db2 list  tablespaces show detail


 表空间标识                          = 2
 名称                                = USERSPACE1
 类型                                = 数据库管理空间
 内容                                = 所有持久数据。大型表空间。
 状态                   = 0x0000
   详细解释:
     正常
 总计页数                            = 46912
 可用页数                            = 46880
 已用页数                            = 14112
 可用页数                            = 32768
 高水位标记(页)                    = 14112
 页大小(以字节计)                  = 4096
 扩展数据块大小(页)                = 32
 预取大小(页)                      = 32
 容器数                              = 1


3、要查看表占用空间情况:

[db2inst2@localhost ~]$  du -sh /home/db2inst2/
2.0G /home/db2inst2/
[db2inst2@localhost ~]$ 


[db2inst2@localhost shell]$ db2 -tsvf showtabs_size.sql 
select substr(tbsp_name,1,20) as TABLESPACE_NAME,substr(tbsp_content_type,1,10) as TABLESPACE_TYPE,sum(tbsp_total_size_kb)/1024 as TOTAL_MB,sum(tbsp_used_size_kb)/1024 as USED_MB,sum(tbsp_free_size_kb)/1024 as FREE_MB,tbsp_page_size AS PAGE_SIZE from SYSIBMADM.TBSP_UTILIZATION group by tbsp_name,tbsp_content_type,tbsp_page_size order by 1


TABLESPACE_NAME      TABLESPACE_TYPE TOTAL_MB             USED_MB              FREE_MB              PAGE_SIZE  
-------------------- --------------- -------------------- -------------------- -------------------- -----------
SYSCATSPACE          ANY                               96                   86                    9        4096
SYSTOOLSPACE         LARGE                             32                    0                   31        4096
TEMPSPACE1           SYSTEMP                            0                    0                    0        4096
USERSPACE1           LARGE                            183                  179                    3        4096


  4 条记录已选择。



[db2inst2@localhost shell]$ db2 "select count(*) from empl"


1          
-----------
    3120000


  1 条记录已选择。

4、表删drop 表

[db2inst2@localhost shell]$  db2 "drop table empl"
DB20000I  SQL 命令成功完成。
[db2inst2@localhost shell]$ du -sh /home/db2inst2/
2.0G /home/db2inst2/
[db2inst2@localhost shell]$ 


5、空间没有被回收


[db2inst2@localhost shell]$ db2 -tsvf showtabs_size.sql 
select substr(tbsp_name,1,20) as TABLESPACE_NAME,substr(tbsp_content_type,1,10) as TABLESPACE_TYPE,sum(tbsp_total_size_kb)/1024 as TOTAL_MB,sum(tbsp_used_size_kb)/1024 as USED_MB,sum(tbsp_free_size_kb)/1024 as FREE_MB,tbsp_page_size AS PAGE_SIZE from SYSIBMADM.TBSP_UTILIZATION group by tbsp_name,tbsp_content_type,tbsp_page_size order by 1


TABLESPACE_NAME      TABLESPACE_TYPE TOTAL_MB             USED_MB              FREE_MB              PAGE_SIZE  
-------------------- --------------- -------------------- -------------------- -------------------- -----------
SYSCATSPACE          ANY                               96                   86                    9        4096
SYSTOOLSPACE         LARGE                             32                    0                   31        4096
TEMPSPACE1           SYSTEMP                            0                    0                    0        4096
USERSPACE1           LARGE                            183                   55                    3        4096


  4 条记录已选择。


[db2inst2@localhost shell]$  db2 list  tablespaces show detail
 表空间标识                          = 2
 名称                                = USERSPACE1
 类型                                = 数据库管理空间
 内容                                = 所有持久数据。大型表空间。
 状态                   = 0x0000
   详细解释:
     正常
 总计页数                            = 46912
 可用页数                            = 46880
 已用页数                            = 14112
 可用页数                            = 32768
 高水位标记(页)                    = 14112
 页大小(以字节计)                  = 4096
 扩展数据块大小(页)                = 32
 预取大小(页)                      = 32
 容器数                              = 1




5、执行 Reducing the HWM in Automatic Storage Table Spaces

[db2inst2@localhost shell]$ db2 "ALTER TABLESPACE USERSPACE1 REDUCE MAX "
DB20000I  SQL 命令成功完成。


 表空间标识                          = 2
 名称                                = USERSPACE1
 类型                                = 数据库管理空间
 内容                                = 所有持久数据。大型表空间。
 状态                   = 0x0000
   详细解释:
     正常
 总计页数                            = 14144
 可用页数                            = 14112
 已用页数                            = 14112
 可用页数                            = 0
 高水位标记(页)                    = 14112
 页大小(以字节计)                  = 4096
 扩展数据块大小(页)                = 32
 预取大小(页)                      = 32
 容器数                              = 1

6、查看空间已经回收
[db2inst2@localhost shell]$ du -sh /home/db2inst2/
1.8G /home/db2inst2/
[db2inst2@localhost shell]$ 
[db2inst2@localhost shell]$ db2 -tsvf showtabs_size.sql 
select substr(tbsp_name,1,20) as TABLESPACE_NAME,substr(tbsp_content_type,1,10) as TABLESPACE_TYPE,sum(tbsp_total_size_kb)/1024 as TOTAL_MB,sum(tbsp_used_size_kb)/1024 as USED_MB,sum(tbsp_free_size_kb)/1024 as FREE_MB,tbsp_page_size AS PAGE_SIZE from SYSIBMADM.TBSP_UTILIZATION group by tbsp_name,tbsp_content_type,tbsp_page_size order by 1


TABLESPACE_NAME      TABLESPACE_TYPE TOTAL_MB             USED_MB              FREE_MB              PAGE_SIZE  
-------------------- --------------- -------------------- -------------------- -------------------- -----------
SYSCATSPACE          ANY                               96                   86                    9        4096
SYSTOOLSPACE         LARGE                             32                    0                   31        4096
TEMPSPACE1           SYSTEMP                            0                    0                    0        4096
USERSPACE1           LARGE                             55                   55                    0        4096


  4 条记录已选择。

阅读(3783) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~