JOIN 谓词 选择率 参考:
Join Selectivity =1/max(colcard(inner table. joincol), colcard(outer table. joincol))
JOIN 基数估算
Join Cardinality =Join Selectivity * filtered cardinality(inner table)
*filtered cardinality(outer table)
db2expln 有个参数是-p ,查看包的执行计划
如何把生产环境某张表的统计信息移动到测试环境上
for specific table, use -t
for example:
db2look -d sample -m -t department
or if do not want commit and runstats to be generated
db2look -d sample -m -t department -c -r
抓取SQL语句的执行计划
1.首次执行需要建立执行计划表:
db2 "connect to testdb1";
db2 -tvf /home/db2inst1/sqllib/misc/EXPLAIN.DDL
2.设置为解释模式,并不执行发出的SQL命令:
db2 "set current explain mode explain"
3.执行SQL语句:
select count(0) from db2inst1.t1
解释模式下并不执行SQL语句:
SQL0217W The statement was not executed as only Explain information requests
are being processed. SQLSTATE=01604
4.关闭解释模式:
db2 "set current explain mode no "
5.格式化输出文件:
db2exfmt -d testdb1 -g TIC -w -l -s % -n % -o db2exmt.out