首页 > 新闻系统 > 编程天地 > 文章正文

讲解DB2数据库性能调整的十个实用技巧

2008-05-08 09:13:49 来源:赛迪网 作者:Alizze 点击:
本文着重介绍了DB2数据库性能调整的十个实用技巧,详细内容请读者参考下文。(本文主要针对e-business OLTP10个性能方面的Tips)

      本文着重介绍了DB2数据库性能调整的十个实用技巧,详细内容请读者参考下文。(本文主要针对e-business OLTP10个性能方面的Tips)

1. SQL COST ANALYSIS

许多情况下,一个简单的SQL就可能让DB2系统处于尴尬的状态。调整参数也不能解决此问题。由于DBA很难去改变这些垃圾SQL的现状,所以留给DBA的就是下面的情况:

(1). Change or add indexes

(2). Change clustering

(3). Change catalog statistics.

注:一个SQL语句的cost= 每次执行的资源代价 *执行的次数。

目前,DBA面临的挑战就是要找到那些有很高cost的语句,并且尽力去减少它的代价。可以借助DB2 Explain 工具或者DB2 UDB SQL Event Monitor数据来分析SQL语句的代价。尤其是对SQL Event Monitor的数据分析,但这么做需要耗费很大的精力和时间。

一般DBA的流程是:

(1). Create an SQL Event Monitor, write to file:

$> db2 "create event monitor SQLCOST for statements write to ..."

(2). Activate the event monitor (be sure ample free disk space is available):

$> db2 "set event monitor SQLCOST state = 1"

(3). Let the application run.

(4). Deactivate the event monitor:

$> db2 "set event monitor SQLCOST state = 0"

(5). Use the DB2-supplied db2evmon tool to format the raw SQL Event Monitor data (hundreds of megabytes of free disk space may be required depending on SQL throughput rates):

$> db2evmon -db DBNAME -evm SQLCOST

> sqltrace.txt

(6). Browse through the formatted file scanning for unusually large cost numbers, a time-consuming process:

$> more sqltrace.txt

(7). Undertake a more complete analysis of the formatted file that attempts to identify unique statements (independent of literal values), each unique statement's frequency (how many times it occurred), and the aggregate of its total CPU, sort, and other resource costs. Such a thorough analysis could take a week or more on just a 30-minute sample of application SQL activity.

为了以最快的速度找到相应的SQL,我们可以考虑上文讲过的一些方法:

针对第4个tip:计算每个交易从一个table里面取出的行数。如果数值很高,就可以找到相应的语句。

针对第3个tip:计算每个tablespace的asynchronous read percentage and physical I/O read rates.如果一个tablespace有很高的asynchronous read percentage 和高于平均的physical I/O read rates,那么有可能这个tablesapce里面有table scan情况。从catalog中可以找寻tablespace中相应的table(如果一个tablespace上只有一个表,那么很容易定位了),然后从SQL Event Monitor 中寻找相关的table。这样也可以缩小范围。

观察DB2 Explain信息,寻找可疑的地方。有时候,经常执行的、而且是代价比较低的语句也会疯狂占用系统资源!

很多时候,我们可以充分借助工具!这样能省时省力。

Staying in Tune

需要特别注意的是,性能优化不能仅仅只是消除那些好的SQL语句,也要保证合理的物理构架,确保高性能的结果、内存分配在pool和heap中,I/O都在DISk之间平衡分布。

2. BUFFER POOL OPTIMIZATION

目前一般的系统内存都可以达到2G,4G,8G了,但是DB2缺省的IBMDEFAULTBP只有16M。在此情况下,一般可以建立一个buffer pool 给SYSCATSPACE catalog tablespace, 一个buffer pool给 TEMPSPACE t

9 7 3 1 2 3 4 4 8 :

精彩推荐
焦点大图推荐
本类热门文章

论坛美图

广告联系 | 版权说明 | 意见建议 | 加入收藏 | 军网站群 [ 军软件园 - 军软件商城 - 军软件园论坛 ]

电信与信息服务业务经营许可证:京ICP证050203