情景:总所周知,DB2的表空间(数据)在节点中存储是根据每张表的分区键来分布的,如果分区键建的不好,会直接导致表空间在各节点的占用大小不均匀,久而久之,其中一个或几个节点的大小已所剩无几,其他的却依旧充足,这样就不得不扩展空间不足的节点大小,对性能也会有所影响。

检查:

1、查看表空间使用情况,YOUR_SPACENAME为查看的表空间名

SELECT * FROM SYSIBMADM.TBSP_UTILIZATION WHERE TBSP_NAME='YOUR_SPACENAME';

每个节点各为一条数据,'DBPARTITIONNUM'为节点序号,'TBSP_UTILIZATION_PERCENT'为各节点使用比例,'TBSP_ID'为表空间序号

2、选取其中使用率较高与较低的两组节点进行比较每张表的数据分布情况,$1、$3为节点序号,$2为表空间序号,$4为schema名称

 db2 -x "select 'select '''||trim(a.tabschema)||'.'||trim(a.tabname)||''' as tabname, count(*) from '||trim(a.tabschema)||'.'||trim(a.tabname)||' where dbpartitionnum('||b.colname||')=$1 with ur;' from syscat.tables a ,syscat.columns b where a.tbspaceid=$2  and a.tabschema=b.tabschema  and a.tabschema=$4 and a.tabname=b.tabname and b.COLNo=0 " > cnt1.sql
db2 -txf cnt1.sql > cnt1.out
db2 -x "select 'select '''||trim(a.tabschema)||'.'||trim(a.tabname)||''' as tabname, count(*) from '||trim(a.tabschema)||'.'||trim(a.tabname)||' where dbpartitionnum('||b.colname||')=$3 with ur;' from syscat.tables a ,syscat.columns b where a.tbspaceid=$2 and a.tabschema=b.tabschema and a.tabschema=$4 and a.tabname=b.tabname and b.COLNo=0 " > cnt2.sql
db2 -txf cnt2.sql > cnt2.out
diff cnt1.out cnt2.out>diff.out

输出结果diff.out即此schema下所有表在两个节点数据分布差异情况

3、找出记录数相差很大的表,查看表的SQL定义

db2look -d [dbname] -i [userName] -w [password] -z [schemaName] -t [tableName] -e -nofed -o tableddl.sql

或者使用连接工具生成DDL查看

4、根据实际情况进行数据清理或者重新建表

补充:也可直接查看某一具体表在个节点的数据分布

select 'aaa.bbb' as tabname,count(*) as cnt ,dbpartitionnum(hash字段) from aaa.bbb group by dbpartitionnum(hash字段) with ur;

最新文章

  1. Linux下的TeXlive 2015 中文问题
  2. [Maven] 变态问题收集
  3. java多线程的等待唤醒机制及如何解决同步过程中的安全问题
  4. 电赛总结(四)——波形发生芯片总结之AD9834
  5. mysql之触发器before和after的区别
  6. CentOS 6.4 使用第三方源
  7. Hadoop-2.2.0中文文档—— Common - CLI MiniCluster
  8. A SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'Lucene40' does not exist.
  9. Oracle 与Mysql区别
  10. 任务调度框架Quartz原理简介
  11. viewpager 设置预加载项
  12. 根据class显示或隐藏多个div
  13. 企业级仓库harbor搭建
  14. 【转】学习Java虚拟机没用? 听听当事人是怎么说的!
  15. 【转】typedef和#define的用法与区别
  16. 监控命令之tsar
  17. node-sass 安装
  18. ln: operation not permitted
  19. LuoguP3183 [HAOI2016]食物链 记忆化搜索
  20. rem 的使用

热门文章

  1. matlab基本函数 randn,rand,orth
  2. Spring Cloud API网关服务 5.2
  3. 【err】开启Persistence-M模式-Check failed: err == CUBLAS_STATUS_SUCCESS (1 vs. 0) : Create cublas handle failed
  4. 05点睛Spring MVC 4.1-服务器端推送
  5. Word中如何加载EndNote
  6. InstallerProjects打包
  7. mysql 查询的所有操作
  8. 在ensp上配置通过Telent登录系统
  9. EFCore 调试远程SqlServer数据库提示信号灯超时时间已到
  10. (三)spring Security 从数据库中检索用户名和密码