ITPUB??ì3
新一届的微软MVP评选已经开始,欢迎各位推荐!
ITPUB论坛 » Oracle专题深入讨论 » truncate 实现机制

标题: truncate 实现机制
离线 lcmlsj
lost my way ,不知奔向何方!


精华贴数 0
个人空间 0
技术积分 6669 (195)
社区积分 15 (8634)
注册日期 2002-4-9
论坛徽章:16
ITPUB元老会员2007贡献徽章授权会员BLOG每日发帖之星ITPUB新首页上线纪念徽章数据库板块每日发贴之星
数据库板块每日发贴之星     

发表于 2006-7-22 21:28 
truncate 实现机制

在dba-object视图中object_id 和data_object_id的区别?
对表执行delete操作时,object_id 和data_object_id得值都不变。
对表执行truncate操作时,object_id 值不变,data_object_id得值增加2,不知什么意思,2 表示什么?


__________________
只看该作者    顶部
离线 lcmlsj
lost my way ,不知奔向何方!


精华贴数 0
个人空间 0
技术积分 6669 (195)
社区积分 15 (8634)
注册日期 2002-4-9
论坛徽章:16
ITPUB元老会员2007贡献徽章授权会员BLOG每日发帖之星ITPUB新首页上线纪念徽章数据库板块每日发贴之星
数据库板块每日发贴之星     

发表于 2006-7-22 21:29 
select * from dba_objects
where object_name='T';

OBJECT_ID DATA_OBJECT_ID
---------- --------------
12756 12880
truncate table t;
OBJECT_ID DATA_OBJECT_ID
---------- --------------
12756 12882


__________________
只看该作者    顶部
离线 lcmlsj
lost my way ,不知奔向何方!


精华贴数 0
个人空间 0
技术积分 6669 (195)
社区积分 15 (8634)
注册日期 2002-4-9
论坛徽章:16
ITPUB元老会员2007贡献徽章授权会员BLOG每日发帖之星ITPUB新首页上线纪念徽章数据库板块每日发贴之星
数据库板块每日发贴之星     

发表于 2006-7-22 21:29 
查oracle文档:
OBJECT_ID NUMBER NOT NULL Dictionary object number of the object
DATA_OBJECT_ID NUMBER
Dictionary object number of the segment that contains the object



Note: OBJECT_ID and DATA_OBJECT_ID display data dictionary metadata. Do not confuse these numbers with the unique 16-byte object identifier (object ID) that the Oracle Database assigns to row objects in object tables in the system.


__________________
只看该作者    顶部
离线 biti_rainy
人生就是如此



精华贴数 37
个人空间 0
技术积分 110956 (4)
社区积分 11784 (124)
注册日期 2001-12-12
论坛徽章:41
现任管理团队成员ITPUB长老会成员ITPUB元老年度论坛发贴之星年度论坛发贴之星ITPUB北京九华山庄2008年会纪念徽章
管理团队2007贡献徽章参与2007年甲骨文全球大会(中国上海)纪念ITPUB北京香山2007年会纪念徽章管理团队2006纪念徽章会员2007贡献徽章会员2006贡献徽章

发表于 2006-7-22 22:58 
truncate 的时候data_object_id重新生成,HWM被移动到紧靠segment header 的block。 data_object_id 的变化表示 segment 重新产生过。至于增加2,这个2并没有什么含义,只是 增大而已。

比如 一个大查询在执行,表被truncate ,当查询继续fetch 的时候将发现 block 中 data_object_id 和 新的segment 的 data_object_id 不一样了,于是返回错误。错误编号我忘记了。


__________________
眼界决定边界,态度决定高度
blog:
人生就是如此
只看该作者    顶部
离线 lcmlsj
lost my way ,不知奔向何方!


精华贴数 0
个人空间 0
技术积分 6669 (195)
社区积分 15 (8634)
注册日期 2002-4-9
论坛徽章:16
ITPUB元老会员2007贡献徽章授权会员BLOG每日发帖之星ITPUB新首页上线纪念徽章数据库板块每日发贴之星
数据库板块每日发贴之星     

发表于 2006-7-23 07:28 
谢谢你 biti_rainy  master;good  wishes to you and your 柔嘉维则!
关于:比如 一个大查询在执行,表被truncate ,当查询继续fetch 的时候将发现 block 中 data_object_id 和 新的segment 的 data_object_id 不一样了,于是返回错误。错误编号我忘记了。
我准备做一下实验。


__________________
只看该作者    顶部
离线 wing hong
版主



精华贴数 0
个人空间 0
技术积分 1234 (1422)
社区积分 9 (11219)
注册日期 2002-8-7
论坛徽章:3
管理团队成员管理团队2006纪念徽章会员2006贡献徽章   
      

发表于 2006-7-25 11:00 
Other  interesting info about truncate comes from this mtalink note <286363.1>
"
When a truncate/drop is issued,

1.the foreground first acquires the "RO" enqueue in exclusive mode,
2.then cross instance calls (or one call if it is a single object) are issued
(the "CI" enqueue is acquired for cross instance call)
3.The CKPT processes on each of instances requests the DBWR to write
the dirty buffers to the disk and invalidate all the clean buffers.
4. After DBWR finishes writing, the foreground process releases the RO
enqueue.

In effect this enqueue serializes the truncate/drop operations given concurrently.
"

I had experience with slow truncate due to the overloading of checkpoint process.


只看该作者    顶部
离线 wing hong
版主



精华贴数 0
个人空间 0
技术积分 1234 (1422)
社区积分 9 (11219)
注册日期 2002-8-7
论坛徽章:3
管理团队成员管理团队2006纪念徽章会员2006贡献徽章   
      

发表于 2006-7-25 11:35 
another useful metalink note is <287429.1>


只看该作者    顶部
离线 wing hong
版主



精华贴数 0
个人空间 0
技术积分 1234 (1422)
社区积分 9 (11219)
注册日期 2002-8-7
论坛徽章:3
管理团队成员管理团队2006纪念徽章会员2006贡献徽章   
      

发表于 2006-7-25 11:38 
And in note <286363.1> , it says " RO enqueue known as "Multiple object resue" "  . I think it should read "Multiple object reuse".  You can also find this in 10g


只看该作者    顶部
离线 Yong Huang
版主



精华贴数 2
个人空间 0
技术积分 4192 (339)
社区积分 129 (3014)
注册日期 2001-10-9
论坛徽章:6
现任管理团队成员ITPUB元老管理团队2006纪念徽章会员2006贡献徽章授权会员2008年新春纪念徽章
      

发表于 2006-7-25 12:22 


QUOTE:
最初由 biti_rainy 发布
truncate 的时候data_object_id重新生成,HWM被移动到紧靠segment header 的block。 data_object_id 的变化表示 segment 重新产生过。至于增加2,这个2并没有什么含义,只是 增大而已。


I'm puzzled by the increment 2. Why 2? This 2 seems to be independent of whether the table has dependent objects (indexes, etc.) or how many rows are in the table.

By the way, if the table is already empty, truncate won't increment data_object_id. But alter table move always does. The increment due to table move seems to be related to the number of blocks in the table. In this sense, we can say alter table move definitely recreates the segment but saying truncate does it too is a little far-fetched, in my opinion.

One more case where data_object_id increments is, similar to table "rebuild" or move, alter index rebuild.

Other useful things worth remembering. You use data_object_id in v$bh and x$bh, but object_id in v$locked_object.

Yong Huang


只看该作者    顶部
离线 Yong Huang
版主



精华贴数 2
个人空间 0
技术积分 4192 (339)
社区积分 129 (3014)
注册日期 2001-10-9
论坛徽章:6
现任管理团队成员ITPUB元老管理团队2006纪念徽章会员2006贡献徽章授权会员2008年新春纪念徽章
      

发表于 2006-7-25 12:29 


QUOTE:
最初由 wing hong 发布
And in note <286363.1> , it says " RO enqueue known as "Multiple object resue" "  . I think it should read "Multiple object reuse".  You can also find this in 10g

Very glad to know you're still alive, Wing!

Yes, it's "Multiple object reuse". You can find it in v$lock_type.name where type = 'RO', and description is 'Coordinates flushing of multiple objects'.

Yong Huang


只看该作者    顶部
相关内容


CopyRight 1999-2006 itpub.net All Right Reserved.
北京皓辰广域网络信息技术有限公司. 版权所有
E-mail:Webmaster@itpub.net
京ICP证:010037号 联系我们 法律顾问