签到成功

知道了

CNDBA社区CNDBA社区

DB2开启db2advis

2021-10-01 16:29 1597 0 原创 DB2
作者: hbhe0316

cd /home/db2inst1/sqllib/misc/
db2 connect to testdb
db2 -tvf EXPLAIN.DDLhttp://www.cndba.cn/hbhe0316/article/4793

如果不是schema用户,需要schema用户,
db2advis -d -i 1.sql -t 5 -a db2inst1/password -n db2inst1 -q db2inst1 http://www.cndba.cn/hbhe0316/article/4793

如果是schema用户
db2advis -d -i 1.sql -t 5

http://www.cndba.cn/hbhe0316/article/4793

db2expln
1) method 1
db2expln -d -f top1.sql -t -z @ -g http://www.cndba.cn/hbhe0316/article/4793

2) method 2
db2expln -d -t -g -q “statement “ http://www.cndba.cn/hbhe0316/article/4793

db2 “explain plan for select …”

db2exfmt -d -l -o /tmp/exfmt.txt
—————or——————
db2 “set current explain mode explain”
db2 “select …”
db2 “set current explain mode no”
db2exfmt -d -l -o /tmp/exfmt.txt

db2expln -d -f top1.sql(语句末不带;) -t -z @ -g
db2expln -d -t -g -q “sql statement”
db2expln -d -statement “sql statement” -g -o /tmp/expln.txt
http://www.cndba.cn/hbhe0316/article/4793

db2 “select r.routineschema,r.routinename,d.bname,d.bschema from syscat.routines r,syscat.routinedep d where r.routineschema=’DB2INST1’
and r.routinename=’SP’ and r.specificname=d.specificname and d.btype=’K’”
db2expln -d -c -p -g -o /tmp/sp.expln

reorg table
db2 “select ‘reorg table ‘||rtrim(tabschema)||’.’||tabname||’;’ from syscat.tables where type=’T’”

http://www.cndba.cn/hbhe0316/article/4793
http://www.cndba.cn/hbhe0316/article/4793

reorg indexes
db2 “select ‘reorg indexes all for table ‘||rtrim(tabschema)||’.’||tabname|| ‘;’ from syscat.tables where type=’T’”

表离线reorg
db2 reorg table db2inst1.test
在线reorg
db2 reorg table db2inst1.test inplace allow write access

http://www.cndba.cn/hbhe0316/article/4793

通过下列命令获得表或者索引的重组信息
db2 list history reorg all for dbname

其他临时表空间离线reorg
db2 "reorg table schema.tabname using <SysTMPTbs>"

只清理脏页的reorg
db2 "reorg indexes all for table schema.tabname cleanup only all"

db2 “select ‘runstats on table ‘||rtrim(tabschema)||’.’||tabname||’ with distribution and detailed indexes all;’ from syscat.tables where type=’T’”http://www.cndba.cn/hbhe0316/article/4793

runstats常用命令
db2 “runstats on table db2inst1.test with distribution and detailed indexes all”
收集列组统计信息
db2 “runstats on table db2inst1.test on columns((col_1,col_2)) with distribution and indexes all”
收集所有列统计分布信息,同时收集部分列列组统计信息
db2 “runstats on table db2inst1.test on all columns and columns((col_1,col_2)) with distribution and sampled detailed indexes all”
收集部分列统计分布信息,同时收集部分列列组统计信息
db2 “runstats on table db2inst1.test on columns(col_1,col_2,(col_3,col_4)) with distribution and sampled detailed indexes all”

对索引进行runstats
db2 “runstats on table schema.tabname for index schema.indname”

db2 “select ‘rebind package ‘||rtrim(pkgschema)||’.’||pkgname||’;’ from syscat.packages”
db2rbind -l db2rbind.log all

版权声明:本文为博主原创文章,未经博主允许不得转载。

Linux,oracle

用户评论
* 以下用户言论只代表其个人观点,不代表CNDBA社区的观点或立场
hbhe0316

hbhe0316

关注

1.只有承认无知,才能装下新的东西; 2.进步来自一点点滴滴的积累; 3.广博让你更优秀,而专业让你无法替代; 4.挫折和失败能够转换为一种财富。

  • 889
    原创
  • 1
    翻译
  • 13
    转载
  • 24
    评论
  • 访问:2667527次
  • 积分:1523
  • 等级:核心会员
  • 排名:第6名
精华文章
    最新问题
    查看更多+
    热门文章
      热门用户
      推荐用户
        Copyright © 2016 All Rights Reserved. Powered by CNDBA · 皖ICP备2022006297号-1·

        QQ交流群

        注册联系QQ