DB2 优化收集

来源:互联网 发布:软件测试培训机构 编辑:程序博客网 时间:2024/04/20 15:38


1.使用db2advis分析指定的sql语句当前的执行成本,以及在db2建议下建立索引后的执行成本
db2advis -d TESTDB -i 1.sql
-d: 数据库名
-i: sql语句,以分号结尾

2.更新单个表的统计信息
db2 runstats on table db2admin.tab1 with distribution and indexes all

3.更新整个库的统计信息
db2 reorgchk update statistics on table all

4.进行整个数据库重组检查,已决定是否需要进行数据重组
db2 reorgchk current statistics on table all

5.进行单个表重组检查,已决定是否需要进行数据重组
db2 reorgchk current statistics on table db2admin.tbl1

6.对需要重组的表进行重组
db2 reorg on table db2admin.tbl1

7.重新绑定数据库的所有package
db2rbind kckopen -l db2rbind.log all

8.察看当前执行sql语句的时间,文本
db2 get snapshot for dynamic sql on testdb

优化步骤:
1.收集统计信息
2.进行reorgchk current statistics,以判断是否需要重组
3.对需要的表进行重组
4.对重组后的表再次收集统计信息
5.重新绑定数据库package
6.db2 flush package cache
7.执行应用

8:清空表
ALTER TABLE tbl  Activate NOT LOGGED INITIALLY WITH EMPTY TABLE; 

原创粉丝点击