楼主: myfriend2010

[FAQ] sql 使CPU使用100%,棘手!

[复制链接]
招聘 : c/c++研发
论坛徽章:
45
技术图书徽章
日期:2014-03-10 14:09:192012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-01-04 11:51:22ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
41#
发表于 2007-12-7 22:54 | 只看该作者
明天看一看访问计划,如果一切没有问题你可以试一下手工单独运行那个查询看看有没有高cpu的迹象

使用道具 举报

回复
招聘 : c/c++研发
论坛徽章:
45
技术图书徽章
日期:2014-03-10 14:09:192012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-01-04 11:51:22ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
42#
发表于 2007-12-7 22:57 | 只看该作者
原帖由 myfriend2010 于 2007-12-7 23:50 发表


中午的时候我看了一下,cost正常!和前边9月份的cost基本上一致!


4个分区都在同一个磁盘上!

也就是说都在同一物理节点上了,这样的话分区间通讯应该直接走共享内存(不知道windows是不是这样),这样的话没有了i/o wait,大量的内存操作很有可能造成高cpu的现象。
如果发现在使用了一个分区键依然存在大量TQ的情况就需要看看为什么还会有TQ,否则看一看是否有哪个join可能造成这个问题

使用道具 举报

回复
招聘 : Linux运维
论坛徽章:
235
紫蜘蛛
日期:2007-09-26 17:05:46玉兔
日期:2007-09-26 17:05:05现任管理团队成员
日期:2011-05-07 01:45:08玉兔
日期:2006-08-29 20:38:48紫蜘蛛
日期:2007-09-26 17:05:34阿斯顿马丁
日期:2013-11-19 10:38:16奔驰
日期:2013-10-16 09:08:58红旗
日期:2014-01-09 11:57:39路虎
日期:2013-08-13 14:52:35林肯
日期:2015-05-19 13:01:16
43#
 楼主| 发表于 2007-12-7 23:13 | 只看该作者
单独执行:有CPU偏高的迹象,但是小于100%,有一段持续的时间,不过最终可以运行出来!

使用道具 举报

回复
招聘 : c/c++研发
论坛徽章:
45
技术图书徽章
日期:2014-03-10 14:09:192012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-01-04 11:51:22ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
44#
发表于 2007-12-7 23:16 | 只看该作者
和9月份的good case相比呢?用db2batch单独执行一下这个query,for both 9月份的good case和10月份的 bad case

使用道具 举报

回复
论坛徽章:
21
在线时间
日期:2007-07-25 04:01:022012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:23马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:09:23
45#
发表于 2007-12-8 08:11 | 只看该作者
How many CPUs do you have for your server?

You seem to have turned on intra-partition parallelism, and you have four nodes in the single server?

You may check out in total how many db2 agents serving this particular query? Is your server capable of providing the adequate processing power?

Also, you may check out the access plan to find out the difference with single column as partitioning key or two columns as partitioning key, respectively.

Data volume is another key factor in determining a proper access plan, and the estimated joined cardinality(the uniqueness of your data).

You may share the reason of having two columns as partitioning key in one of your table.

Also, CPU hitting 100% when a query is processed is not necessary a bad thing as long as the query can finish in shorter time:
  - A good access plan should make FULL use of the available system resource, AND
  - A good access plan should know the system resource limit and make use of the system resource WITHIN acceptable limit.

使用道具 举报

回复
论坛徽章:
21
在线时间
日期:2007-07-25 04:01:022012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:23马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:09:23
46#
发表于 2007-12-8 10:04 | 只看该作者
You may also check out your storage performance, and the active prefetchers serving the query.

If the physical system resource is not adequate, you may experience problem no matter what has been done.

Waiting time will increase exponentially if physical hardware is not able to support the system.

使用道具 举报

回复
论坛徽章:
21
在线时间
日期:2007-07-25 04:01:022012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:23马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:142012新春纪念徽章
日期:2012-02-13 15:09:23
47#
发表于 2007-12-8 13:00 | 只看该作者
1) one more point to take note is that ensuring the tables having the same partitioning key does not guarantee the tables can be locally joined if these tables happen to be in different tablespaces, and these tablespaces are in different nodegroups.

2) For this case, since the (09) query is running fine, you may try to truncate (09) tables, and load the (10) data into (09) tables, and observe the difference, i.e. loading (10) data into both (09) and (10) tables, and check the performance difference.

使用道具 举报

回复
招聘 : Linux运维
论坛徽章:
235
紫蜘蛛
日期:2007-09-26 17:05:46玉兔
日期:2007-09-26 17:05:05现任管理团队成员
日期:2011-05-07 01:45:08玉兔
日期:2006-08-29 20:38:48紫蜘蛛
日期:2007-09-26 17:05:34阿斯顿马丁
日期:2013-11-19 10:38:16奔驰
日期:2013-10-16 09:08:58红旗
日期:2014-01-09 11:57:39路虎
日期:2013-08-13 14:52:35林肯
日期:2015-05-19 13:01:16
48#
 楼主| 发表于 2007-12-8 21:36 | 只看该作者
今天和狼QQ了一下,最终分析很有可能是存储过程中临时表造成的!

使用道具 举报

回复
招聘 : Linux运维
论坛徽章:
235
紫蜘蛛
日期:2007-09-26 17:05:46玉兔
日期:2007-09-26 17:05:05现任管理团队成员
日期:2011-05-07 01:45:08玉兔
日期:2006-08-29 20:38:48紫蜘蛛
日期:2007-09-26 17:05:34阿斯顿马丁
日期:2013-11-19 10:38:16奔驰
日期:2013-10-16 09:08:58红旗
日期:2014-01-09 11:57:39路虎
日期:2013-08-13 14:52:35林肯
日期:2015-05-19 13:01:16
49#
 楼主| 发表于 2007-12-8 21:36 | 只看该作者
唉!可恶的DB2

使用道具 举报

回复
招聘 : c/c++研发
论坛徽章:
45
技术图书徽章
日期:2014-03-10 14:09:192012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-02-13 15:12:092012新春纪念徽章
日期:2012-01-04 11:51:22ITPUB十周年纪念徽章
日期:2011-11-01 16:21:15现任管理团队成员
日期:2011-05-07 01:45:082011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
50#
发表于 2007-12-9 03:46 | 只看该作者
依然认为是统计数据有问题,你的select count(distinct xxxx)做了没有?如果按照你原先的数据,那个临时表里应该有30多万(还是300多万)记录,但是在使用临时表的计划里只有151。。。这样造成的MSJOIN可能会占用远比预期高的内存空间,在经过几次join以后结果集可能会非常大。你试一下首先在3个表里对cust_id做索引,然后对临时表runstats一下每次,保证db2优化器拿到的统计信息都是真实的

[ 本帖最后由 wangzhonnew 于 2007-12-9 04:47 编辑 ]

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表