赛迪网 > IT技术 数据库 > 精彩更新
  IT资讯搜索
 
IT产品搜索
[程序开发][网管世界][网络安全][数据库技术]
[操作系统][嘉宾聊天·在线访谈][活动集锦]
[精彩专题][Symantec专区][订阅IT技术周刊]
[开发论坛][网管论坛][安全论坛][数据库论坛]
[操作系统论坛][Sybase专区][IBM dW技术专区]
[病毒求助][病毒与漏洞播报][文档·源码下载]

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

发布时间:2008.05.08 05:00     来源:赛迪网    作者:Alizze

3. TABLESPACE ANALYSIS

tablespace snapshot对理解哪些数据被访问和怎么访问的有很大的价值。

db2 "get snapshot for tablespaces on DBNAME"

对每一个tablespace,要注意:

What is the average read time (ms)?

What is the average write time (ms)?

What percentage of the physical I/O is asynchronous (prefetched) vs. synchronous (random)?

What are the buffer pool hit ratios for each tablespace?

How many physical pages are being read each minute?

How many physical and logical pages are being read for each transaction?

对所有的tablespaces,注意:

Which tablespaces have the slowest read and write times? Why?

Containers on slow disks? Are container sizes unequal?

Are the access attributes, asynchronous versus synchronous access, consistent with expectations?

Randomly read tables should have randomly read tablespaces, meaning high synchronous read percentages, usually higher buffer pool hit ratios, and lower physical I/O rates.

对每个tablespace,要注意Prefetch size是Extent size的倍数。如果必要,可以修改tablespace的prefetch size。

显示tablespace信息:db2 "list tablespaces show detail"

显示containers 信息:db2 "list tablespace containers for N show detail"

4. TABLE ACCESS

要查出来每次查询读出的row,

1) db2 "get snapshot for database on DBNAME"

看到多少交易发生,the sum of Commit statements attempted + Rollback statements attempted

2) db2 "get snapshot for tables on DBNAME"

区分出交易读出的row。divide the number of rows read by the number of transactions (RowsPerTX).OLTP一般每次交易从一个table里面读出20 row,如果发现一个交易能读出成百上千行数据,表扫描就可能出现,可能需要看看index是否需要。简单情况下是运行runstats收集信息。

Sample output from "get snapshot for tables on DBNAME" follows:

Snapshot timestamp = 09-25-2000 4:47:09.970811

Database name= DGIDB

Database path= /fs/inst1/inst1/NODE0000/SQL00001/

Input database alias= DGIDB

Number of accessed tables= 8

Table List

Table Schema= INST1

Table Name= DGI_SALES_ LOGS_TB

Table Type= User

Rows Written= 0

Rows Read= 98857

Overflows= 0

Page Reorgs= 0

有很高的Overflows ,就需要re-org table。当一行宽度改变,可能DB2就会把一行放到不同的页中。

5. SORT MEMORY

OLTP应该没有大规模的sort,因为sort会消耗大量的CPU, I/O和时间。

缺省的SORTHEAP = 256*4K=1M,一般是足够了。应该知道sort overflows 的数目和每个交易的sort number。

Db2 "get snapshot for database on DBNAME"

察看如下项目:

Total sort heap allocated= 0

Total sorts = 1

Total sort time (ms)= 8

Sort overflows = 0

Active sorts = 0

Commit statements attempted = 3

Rollback statements attempted = 0

Let transactions = Commit statements attempted + Rollback statements

attempted

Let SortsPerTX= Total sorts / transactions

Let PercentSortOverflows = Sort overflows * 100 / Total sorts

如果PercentSortOverflows 超过3%,可能说明应用中有比较严重的sort SQL。因为大量的overflows说明有大量的sort出现,为零或者小于1时比较理想的。

如果有大量的overflow出现,权宜之计是增加SORTHEAP,但是这么做只是隐藏了问题。根本解决是:要定位SQL,通过调整SQL,INDEX,clustering 来减少sort 代价。

如果SortsPerTX 大于5,说明每个交易的sort数目过多,某些应用可能执行了大量的小复合查询,不会overflow,但是有很小的时间段。但是会消耗大量的CPU。同样是要调整SQL,INDEX,clustering来解决问题。

6. Temporary Tablespaces

临时表空间一般要有3个containers在不同的disk上,可以实现并行I/O,提高sorts, hash joins,或者其他在TEMPSPACE上的动作的性能。

db2 "list tablespaces show detail",可查看临时表空间的container:

Tablespace ID= 1

Name= TEMPSPACE1

Type= System managed space

Contents= Temporary data

State= 0x0000

Detailed explanation: Normal

Total pages= 1

Useable pages= 1

Used pages= 1

Free pages= Not applicable

High water mark (pages)= Not applicable

Page size (bytes)= 4096

Extent size (pages)= 32

Prefetch size (pages)= 96

Number of containers= 3

<<上一页 1 2 3 下一页>>


[ 发表评论 ] 字体[  ] [ 打印 ] [ 进入博客 ] [ 进入论坛 ]  [ 推荐给朋友 ]
  相关文章
· 讲解IBM DB2数据库性能调整的相关命令 (05-07) · Oracle数据库9i在AIX环境下的性能调整 (05-07)
· Oracle数据库SQL语句性能调整的基本原则 (05-06) · 锁现象通常分为死锁和锁等待两种情形 (04-24)
· 实例讲解DB2数据库中SELECT语句高级用法 (04-22) · 在DB2数据库中很难理解的catalog单词 (04-17)
· 提高IMPORT的性能 (04-10) · DB2 9.5的数据库内存保护 (04-10)
· 用一个存储过程实现分步删除数据表记录 (04-09) · 教你快速掌握DB2数据库创建外键时的选项 (04-06)
  客户需求反馈表
* 姓  名:
更多资料  了解方案  认识厂商
* 单位名称:
* 联系电话:
* 电子邮件:
  赛迪推荐  
  手机·资费 ·新品·导购·评测·手机资费·宽带
手机搜索  诺基亚 N73 MOTO Z6
  IT产品 ·笔记本·台式机·服务器·打印·投影
IT产品搜索 
  IT技术 ·开发·网管·安全·数据库·操作系统
  信息化 ·热点·专题·访谈·周刊·方案案例
· 移动信息化市场方兴未艾 企业呼唤标准出台
· 如何把握企业价值差异 避免CRM与SCM脱节
· 齐看四大厂商的SaaS动态 ERP案例分析
· 通方期货CRM解决方案 方正电子公文系统
  IT博客 ·曾剑秋·项立刚·Java学习·网管
  IT技术论坛 ·开发·网管·安全·数据库·系统