12
返回列表 发新帖
楼主: xzh2000

[精华] 用delete删除数据为什么引起sorts(memory)?

[复制链接]
论坛徽章:
1088
金色在线徽章
日期:2007-04-25 04:02:08金色在线徽章
日期:2007-06-29 04:02:43金色在线徽章
日期:2007-03-11 04:02:02在线时间
日期:2007-04-11 04:01:02在线时间
日期:2007-04-12 04:01:02在线时间
日期:2007-03-07 04:01:022008版在线时间
日期:2010-05-01 00:01:152008版在线时间
日期:2011-05-01 00:01:342008版在线时间
日期:2008-06-03 11:59:43ITPUB年度最佳技术原创精华奖
日期:2013-03-22 13:18:30
11#
发表于 2010-12-16 09:46 | 只看该作者
有意思,autotrace不是很准确,有的版本对绑定变量的计划也不准确

使用道具 举报

回复
论坛徽章:
9
ITPUB9周年纪念徽章
日期:2010-10-08 09:28:522010广州亚运会纪念徽章:击剑
日期:2010-11-03 11:00:36ITPUB十周年纪念徽章
日期:2011-11-01 16:25:512012新春纪念徽章
日期:2012-01-04 11:56:19奥运会纪念徽章:摔跤
日期:2012-08-21 10:04:04优秀写手
日期:2014-02-15 06:00:132014年新春福章
日期:2014-02-18 16:44:08马上有对象
日期:2014-02-18 16:44:08马上加薪
日期:2014-05-19 11:17:08
12#
发表于 2010-12-16 10:24 | 只看该作者
这个结果不正常吗??

既然dml操作也会产生consistent gets,那末很有可能在查找要删除列的时候利用sort操作,这个sort操作就是针对consistent gets 的内容。

  这里我想问一个问题,consistent gets的单位是什末??还是,肯定不能是行吧?!

使用道具 举报

回复
论坛徽章:
20
授权会员
日期:2005-11-01 20:24:43生肖徽章:兔
日期:2007-09-26 12:38:46生肖徽章:猪
日期:2007-09-26 17:03:12红孩儿
日期:2007-09-26 17:05:07嫦娥
日期:2007-09-26 17:05:24萤石
日期:2007-10-15 12:31:49ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44ITPUB元老
日期:2007-10-30 16:09:582010年世界杯参赛球队:葡萄牙
日期:2010-01-14 17:00:49生肖徽章:龙
日期:2007-09-26 12:38:32
13#
发表于 2010-12-16 12:03 | 只看该作者

Delayed Index maintenance in Oracle8 and above

Event:12836 - Delayed Index maintenance in Oracle8 and above [ID 69001.1]


Event:12836   
Enable / Disable statement level index buffering in Oracle8 and above.

This event determines whether Oracle attempts to perform statement level
buffering for index operations in Oracle8. Statement level buffering is
a performance enhancement introduced in Oracle 8.0.3.

Levels:
    1  no statement level buffering for non-PDML delete/update
    2  no statement level buffering for PDML
    3  no statement level buffering
    4  force statement level buffering for non-PDML delete/update

Statement level buffering may be disabled even if this event is not set
depending on the operation and use of the index.
Buffering may create a temporary segment for the buffered operations.

Functions:
   See <Function:kauxcbf>
   Compute if we do statement-level buffering and allocate kxib



把这个feature关闭,sort就消失了:


HELLODBA.COM>ALTER SESSION SET EVENTS '12836 trace name context forever, level 3';

Session altered.

HELLODBA.COM>alter system flush shared_pool;

System altered.

HELLODBA.COM>delete from t2 where a<=1;

1 row deleted.

HELLODBA.COM>rollback;

Rollback complete.

HELLODBA.COM>select name,value from v$mystat m, v$statname n where m.statistic#=n.statistic# and upper(name) like '%SORT%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
sorts (memory)                                                         1518
sorts (disk)                                                              0
sorts (rows)                                                          16017

HELLODBA.COM>delete from t2 where a<=1;

1 row deleted.

HELLODBA.COM>select name,value from v$mystat m, v$statname n where m.statistic#=n.statistic# and upper(name) like '%SORT%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
sorts (memory)                                                         1518
sorts (disk)                                                              0
sorts (rows)                                                          16017

HELLODBA.COM>rollback;

Rollback complete.

HELLODBA.COM>ALTER SESSION SET EVENTS '12836 trace name context off';

Session altered.

HELLODBA.COM>alter system flush shared_pool;

System altered.

HELLODBA.COM>delete from t2 where a<=1;

1 row deleted.

HELLODBA.COM>rollback;

Rollback complete.

HELLODBA.COM>select name,value from v$mystat m, v$statname n where m.statistic#=n.statistic# and upper(name) like '%SORT%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
sorts (memory)                                                         1598
sorts (disk)                                                              0
sorts (rows)                                                          16829

HELLODBA.COM>delete from t2 where a<=1;

1 row deleted.

HELLODBA.COM>select name,value from v$mystat m, v$statname n where m.statistic#=n.statistic# and upper(name) like '%SORT%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
sorts (memory)                                                         1599
sorts (disk)                                                              0
sorts (rows)                                                          16830

HELLODBA.COM>


原帖由 Yong Huang 于 2010-12-16 01:52 发表
Autotrace probably has one extra sort because the trace itself creates one.

For others to know,

fuyuncat's cool OraTracer tool is at

http://www.hellodba.com/Download/OraTracer_upgrade.htm

"kxib - index buffering operations" is in Note:175982.1 and
"kxibFinish: kxib Finish index maintenance processing" is in Bug 5477391.

Relevant event for more research is:

$ oerr ora 12837
12837, 00000, "Delayed index maintenance debugging event"
// *Document: NO
// *Cause:
// *Action: Control dumping of debugging information for dealyed maintenance

Yong Huang

使用道具 举报

回复
论坛徽章:
8
2010广州亚运会纪念徽章:柔道
日期:2011-01-31 11:08:262011新春纪念徽章
日期:2011-02-18 11:43:332010广州亚运会纪念徽章:网球
日期:2011-03-18 17:39:042010广州亚运会纪念徽章:手球
日期:2011-04-28 12:09:402010广州亚运会纪念徽章:板球
日期:2011-04-29 12:53:19咸鸭蛋
日期:2011-07-26 15:29:42鲜花蛋
日期:2011-08-08 12:39:06ITPUB十周年纪念徽章
日期:2011-11-01 16:25:51
14#
发表于 2010-12-16 13:49 | 只看该作者

使用道具 举报

回复
论坛徽章:
20
授权会员
日期:2005-11-01 20:24:43生肖徽章:兔
日期:2007-09-26 12:38:46生肖徽章:猪
日期:2007-09-26 17:03:12红孩儿
日期:2007-09-26 17:05:07嫦娥
日期:2007-09-26 17:05:24萤石
日期:2007-10-15 12:31:49ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44ITPUB元老
日期:2007-10-30 16:09:582010年世界杯参赛球队:葡萄牙
日期:2010-01-14 17:00:49生肖徽章:龙
日期:2007-09-26 12:38:32
15#
发表于 2010-12-16 13:53 | 只看该作者
这一特性可以减少一条语句通过索引访问delete/update多条记录产生的db block gets。未启用该特性时,每删除、更新一条记录都要维护一次索引块;启用该特性后,在删除、更新完成后一次性的维护索引。

使用道具 举报

回复
论坛徽章:
86
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11优秀写手
日期:2013-12-18 09:29:11日产
日期:2013-10-17 08:44:39马自达
日期:2013-08-26 16:28:022013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-23 16:55:51马上有房
日期:2014-02-19 11:55:14
16#
发表于 2010-12-16 21:07 | 只看该作者
原帖由 fuyuncat 于 2010-12-16 12:03 发表
Event:12836 - Delayed Index maintenance in Oracle8 and above


Event:12836   
Enable / Disable statement level index buffering in Oracle8 and above.

This event determines whether Oracle attempts to perform statement level
buffering for index operations in Oracle8. Statement level buffering is
a performance enhancement introduced in Oracle 8.0.3.

Levels:
    1  no statement level buffering for non-PDML delete/update
    2  no statement level buffering for PDML
    3  no statement level buffering
    4  force statement level buffering for non-PDML delete/update

Statement level buffering may be disabled even if this event is not set
depending on the operation and use of the index.
Buffering may create a temporary segment for the buffered operations.

Functions:
   See
   Compute if we do statement-level buffering and allocate kxib



把这个feature关闭,sort就消失了:


使用道具 举报

回复
论坛徽章:
86
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11优秀写手
日期:2013-12-18 09:29:11日产
日期:2013-10-17 08:44:39马自达
日期:2013-08-26 16:28:022013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-23 16:55:51马上有房
日期:2014-02-19 11:55:14
17#
发表于 2010-12-16 21:11 | 只看该作者
fuyuncat研究的很internal,学习了!

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
66
ITPUB元老
日期:2005-07-16 18:49:11授权会员
日期:2005-10-30 17:05:33ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44现任管理团队成员
日期:2011-05-07 01:45:08版主3段
日期:2012-05-15 15:24:11
18#
 楼主| 发表于 2010-12-17 19:48 | 只看该作者
谢谢,参加OOW刚回来,发现问题已经差不多了,下周再生产环境上再验证一下。。。

使用道具 举报

回复
论坛徽章:
86
2015中国数据库技术大会纪念徽章
日期:2015-04-24 16:04:24马上有车
日期:2014-02-19 11:55:14马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11优秀写手
日期:2013-12-18 09:29:11日产
日期:2013-10-17 08:44:39马自达
日期:2013-08-26 16:28:022013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-23 16:55:51马上有房
日期:2014-02-19 11:55:14
19#
发表于 2010-12-19 22:16 | 只看该作者
原帖由 xzh2000 于 2010-12-17 19:48 发表
谢谢,参加OOW刚回来,发现问题已经差不多了,下周再生产环境上再验证一下。。。


没上itpub展台溜溜?

使用道具 举报

回复
招聘 : 数据库管理员
论坛徽章:
66
ITPUB元老
日期:2005-07-16 18:49:11授权会员
日期:2005-10-30 17:05:33ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44现任管理团队成员
日期:2011-05-07 01:45:08版主3段
日期:2012-05-15 15:24:11
20#
 楼主| 发表于 2010-12-21 15:01 | 只看该作者
原帖由 sundog315 于 2010-12-19 22:16 发表


没上itpub展台溜溜?


去了,还拿了两只小老虎回家给儿子玩。。。

使用道具 举报

回复

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

本版积分规则 发表回复

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