IT咨询服务Db2数据库sql优化

DB2 SQL语句时间都花在哪个环节?

快照时间是:9:40分其中APP中的语句信息如下:Statement type                             = Dynamic SQL StatementStatement        &nbs...显示全部
快照时间是:9:40分
其中APP中的语句信息如下:
Statement type                             = Dynamic SQL Statement
Statement                                  = Fetch
Section number                             = 1
Application creator                        = NULLID
Package name                               = SYSSN100
Consistency Token                          =
Package Version ID                         =
Cursor name                                = SQL_CURSN100C1
Statement database partition number        = 0
Statement start timestamp                  = 03/02/2015 09:09:09.923204  【注意这里,快照时间是9:40】
Statement stop timestamp                   =
Elapsed time of last completed stmt(sec.ms)= 0.000022
Total Statement user CPU time              = 25.329957   【注意这里,为什么这个时间这么小?】
Total Statement system CPU time            = 0.000000
SQL compiler cost estimate in timerons     = 849507   【这个这么高,有没有影响呢?】
SQL compiler cardinality estimate          = 1
Degree of parallelism requested            = 1
Number of agents working on statement      = 1
Number of subagents created for statement  = 1
Statement sorts                            = 0
Total sort time                            = 0
Sort overflows                             = 0
Rows read                                  = 74208
Rows written                               = 0
Rows deleted                               = 0
Rows updated                               = 0
Rows inserted                              = 0
Rows fetched                               = 0
Buffer pool data logical reads             = 94167
Buffer pool data physical reads            = 9266
Buffer pool temporary data logical reads   = 0
Buffer pool temporary data physical reads  = 0
Buffer pool index logical reads            = 339239
Buffer pool index physical reads           = 54478
Buffer pool temporary index logical reads  = 0
Buffer pool temporary index physical reads = 0
Buffer pool xda logical reads              = 0
Buffer pool xda physical reads             = 0
Buffer pool temporary xda logical reads    = 0
Buffer pool temporary xda physical reads   = 0
Blocking cursor                            = YES
Dynamic SQL statement text:
select count(1) 总行数,count(1)    【完全语句就不方便贴这了】

当时整个系统CPU使用率比较高(90%),已确认CPU使用率高是由DB2引的,这个是其中一个正在执行APP的快照。收起
参与17

查看其它 15 个回答stevenluffy的回答

整体上说就是编译和执行,这方面相关的内存指标是package cache和statement heap 等。余下的就要看执行计划了。具体执行耗费的时间,和硬件指标、统计信息、数据量、sql写法上都有直接关系,通过执行计划能够看出一条sql 在什么环节和操作上耗费了最多时间,也能据此找到优化点。
证券 · 2015-03-15
浏览1198

回答者

stevenluffy 最近回答过的问题

回答状态

  • 发布时间:2015-03-15
  • 关注会员:1 人
  • 回答浏览:1198
  • X社区推广