理解informix中的统计更新

内容提要:
1.介绍统计更新
当一个查询提交后,IDS优化器会算出如何执行这个查询的执行计划,优化器会分配成本到每个执行计划,最后选择成本最低的那个执行计划。

统计更新主要有三个功能
(1)重新编译SPL
(2)删除distribution数据
(3)为优化器搜集必要信息

当计算一个执行计划成本时,优化器必须根据系统表来计算,主要是systables, sysindexes, syscolumns, and sysdistrib,这些表中的某些关键列被使用。

systables (nrows, npused)
sysindexes (levels, leaves, nunique, clust)
syscolumns (colmin , colmax)

nrows - number of rows in the table
npused - number of data pages in the table
levels - number of levels of the btree index
leaves - number of leaves (lowest level) in the index
nunique - number of unique items in the first column of the index
clust - number of io operations required to access the index
colmin - the second lowest value in the table
colmax - the second hightest value in the table

当执行low级别优化时候,会重新更新这些表中相应字段的信息,为得到更多详细表的信息,必须创建data distribution,使用medium 或者 high 级别优化才能产生data distribution信息,并且把这些信息存储到表sysdistrib中。很多情况里面,只使用systables,sysindexes,syscolumns会导致优化器不能选择一个最佳的执行计划,所以必须创建data distribution信息。

2. 统计更新搜集信息
Data distribution信息产生是通过取样本列数据,然后排序,然后创建distributions bins,然后把这些记录插入到sysdistrib表中。
如果是high级别,样本数据是整个表。如果是medium级别,样本数据基于confidence和resolution参数。
基于confidence和resolution的样本数据的尺寸:

Resolution  Confidence  Samples   Resolution  Confidence  Samples 6 f6 z& @# R. U. T, K
2.5 .95 2,963  .25 .95 296,255. W! u! @$ @; n/ _
2.5 .99 4,273  .25 .99 425,104
1.0 .95 18,516  .1 .95 1,851,5937 y/ x: w( A1 S' m$ w8 Z. ^; L
1.0 .99 26,569  .1 .99 2,656,900
.5 .95 74,064  .05 .95 7,406,3759 [3 V( x5 |' V* p+ ^
.5 .99 106,276  .05 .99 10,627,600* I1 X7 r6 }- q/ R

3. 统计更新的效率
提高效率主要有以下几部分。:

提高并行度
在创建data distribution过程中,数据排序是最耗时间的,所以必须打开PDQ,提高排序速度。

增加I/O吞吐
由于HIGH级别扫描整个表,对于大表可以使用light scan提高I/O吞吐。
Use of light scan to improve I/O throughput in big table,It will scan all table in high mode,so if it is a big table,we might use light scan to improve I/O scan.

减少取样数据
你可以通过控制样本数据尺寸扫描来提高统计更新的效率。

说明:
统计更新操作是informix数据库必须执行的操作,对于informix生产系统的性能起着决定性作用。

此文章由 flyinweb 于 2009-11-17 09:47:18 编辑

本日志由 flyinweb 于 2009-11-17 09:26:59 发表,目前已经被浏览 4403 次,评论 0 次;

作者添加了以下标签: informixupdate statistics

引用通告:http://www.517sou.net/Article/320/Trackback.ashx

评论订阅:http://www.517sou.net/Article/320/Feeds.ashx

相关文章

评论列表

    暂时没有评论
(必填)
(必填,不会被公开)