我们的数据库中有一张表数据量超过30亿(当时是v9.1版本),有一天我们需要对该表建一个索引,
建完之后需要做runstats,一开始并没有考虑太多,结果跑了20多分钟,runstats命令报错了,说临时表空间满了,
一检查发现我们数据库的临时表空间只有280G,全表runstats根本没法做。当时很苦恼,自己想了很长时间也没辙,
后来就请教了DB2培训及技术交流群中的大拿“大风”老师,他给我一个方法,
采用样本收集,即快捷且统计信息准确率又高。他给了两种样本统计方式:
runstats on table myschema.customer with distribution on all columns
and detailed indexes all tablesample system (10); ----- 10 percent of the pages
runstats on table myschema.customer on all columns
and sample detailed indexes all tablesample bernoulli (15); ------ 15 percent of all rows
两种 sampling 的区别在于
For BERNOULLI, all data pages will be retrieved through a table scan
but only the percentage of rows as specified through the numeric-literal parameter will be used for the statistics collection.
For SYSTEM, only a percentage of the data pages as specified through the numeric-literal parameter will be retrieved
and used for the statistics collection.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22661144/viewspace-1477205/
,如需转载,请注明出处,否则将追究法律责任。