ITPUB论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

返回列表 发新帖
更多
查看: 7331|回复: 30

truncate 实现机制 [复制链接]

注册会员

lost my way ,不知奔向何方!

精华贴数
0
技术积分
6827
社区积分
15
注册时间
2002-4-9
论坛徽章:
16
ITPUB元老
日期:2006-08-12 12:42:51授权会员
日期:2006-08-12 12:36:09数据库板块每日发贴之星
日期:2006-11-19 01:03:11数据库板块每日发贴之星
日期:2007-04-23 01:05:28会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44BLOG每日发帖之星
日期:2008-06-29 01:02:22
发表于 2006-7-22 21:28:44 |显示全部楼层
在dba-object视图中object_id 和data_object_id的区别?
对表执行delete操作时,object_id 和data_object_id得值都不变。
对表执行truncate操作时,object_id 值不变,data_object_id得值增加2,不知什么意思,2 表示什么?

注册会员

lost my way ,不知奔向何方!

精华贴数
0
技术积分
6827
社区积分
15
注册时间
2002-4-9
论坛徽章:
16
ITPUB元老
日期:2006-08-12 12:42:51授权会员
日期:2006-08-12 12:36:09数据库板块每日发贴之星
日期:2006-11-19 01:03:11数据库板块每日发贴之星
日期:2007-04-23 01:05:28会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44BLOG每日发帖之星
日期:2008-06-29 01:02:22
发表于 2006-7-22 21:29:00 |显示全部楼层
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

使用道具 举报

注册会员

lost my way ,不知奔向何方!

精华贴数
0
技术积分
6827
社区积分
15
注册时间
2002-4-9
论坛徽章:
16
ITPUB元老
日期:2006-08-12 12:42:51授权会员
日期:2006-08-12 12:36:09数据库板块每日发贴之星
日期:2006-11-19 01:03:11数据库板块每日发贴之星
日期:2007-04-23 01:05:28会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44BLOG每日发帖之星
日期:2008-06-29 01:02:22
发表于 2006-7-22 21:29:18 |显示全部楼层
查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.

使用道具 举报

超级版主

人生就是如此

精华贴数
39
技术积分
113462
社区积分
12356
注册时间
2001-12-12
论坛徽章:
73
ITPUB元老
日期:2005-02-28 12:57:00ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41蜘蛛蛋
日期:2011-07-01 08:38:17蛋疼蛋
日期:2011-05-27 08:50:45现任管理团队成员
日期:2011-05-07 01:45:082010广州亚运会纪念徽章:皮划艇
日期:2011-04-26 11:24:14咸鸭蛋
日期:2011-11-09 09:55:402011新春纪念徽章
日期:2011-02-18 11:43:322011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:50
发表于 2006-7-22 22:58:29 |显示全部楼层
truncate 的时候data_object_id重新生成,HWM被移动到紧靠segment header 的block。 data_object_id 的变化表示 segment 重新产生过。至于增加2,这个2并没有什么含义,只是 增大而已。

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

使用道具 举报

注册会员

lost my way ,不知奔向何方!

精华贴数
0
技术积分
6827
社区积分
15
注册时间
2002-4-9
论坛徽章:
16
ITPUB元老
日期:2006-08-12 12:42:51授权会员
日期:2006-08-12 12:36:09数据库板块每日发贴之星
日期:2006-11-19 01:03:11数据库板块每日发贴之星
日期:2007-04-23 01:05:28会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44BLOG每日发帖之星
日期:2008-06-29 01:02:22
发表于 2006-7-23 07:28:39 |显示全部楼层
谢谢你 biti_rainy  master;good  wishes to you and your 柔嘉维则!
关于:比如 一个大查询在执行,表被truncate ,当查询继续fetch 的时候将发现 block 中 data_object_id 和 新的segment 的 data_object_id 不一样了,于是返回错误。错误编号我忘记了。
我准备做一下实验。

使用道具 举报

版主

版主

精华贴数
11
技术积分
3091
社区积分
53
注册时间
2002-8-7
论坛徽章:
15
管理团队2006纪念徽章
日期:2006-04-16 22:44:45ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41管理团队成员
日期:2011-05-07 01:45:082010广州亚运会纪念徽章:马术
日期:2011-02-19 15:47:432011新春纪念徽章
日期:2011-02-18 11:42:502011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:41:012010年世界杯参赛球队:阿根廷
日期:2010-06-18 11:42:452010新春纪念徽章
日期:2010-03-01 11:06:12
发表于 2006-7-25 11:00:55 |显示全部楼层
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.

使用道具 举报

版主

版主

精华贴数
11
技术积分
3091
社区积分
53
注册时间
2002-8-7
论坛徽章:
15
管理团队2006纪念徽章
日期:2006-04-16 22:44:45ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41管理团队成员
日期:2011-05-07 01:45:082010广州亚运会纪念徽章:马术
日期:2011-02-19 15:47:432011新春纪念徽章
日期:2011-02-18 11:42:502011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:41:012010年世界杯参赛球队:阿根廷
日期:2010-06-18 11:42:452010新春纪念徽章
日期:2010-03-01 11:06:12
发表于 2006-7-25 11:35:42 |显示全部楼层
another useful metalink note is <287429.1>

使用道具 举报

版主

版主

精华贴数
11
技术积分
3091
社区积分
53
注册时间
2002-8-7
论坛徽章:
15
管理团队2006纪念徽章
日期:2006-04-16 22:44:45ITPUB十周年纪念徽章
日期:2011-11-01 16:19:41管理团队成员
日期:2011-05-07 01:45:082010广州亚运会纪念徽章:马术
日期:2011-02-19 15:47:432011新春纪念徽章
日期:2011-02-18 11:42:502011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:41:012010年世界杯参赛球队:阿根廷
日期:2010-06-18 11:42:452010新春纪念徽章
日期:2010-03-01 11:06:12
发表于 2006-7-25 11:38:05 |显示全部楼层
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

使用道具 举报

版主

版主

精华贴数
3
技术积分
9663
社区积分
197
注册时间
2001-10-9
论坛徽章:
23
ITPUB元老
日期:2005-02-28 12:57:002011新春纪念徽章
日期:2011-01-25 15:41:012011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-02-18 11:43:33ITPUB年度最佳技术回答奖
日期:2011-04-08 18:37:39现任管理团队成员
日期:2011-05-07 01:45:08ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412011新春纪念徽章
日期:2011-01-04 10:24:02ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
发表于 2006-7-25 12:22:47 |显示全部楼层
最初由 biti_rainy 发布
[B]truncate 的时候data_object_id重新生成,HWM被移动到紧靠segment header 的block。 data_object_id 的变化表示 segment 重新产生过。至于增加2,这个2并没有什么含义,只是 增大而已。
[/B]


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

使用道具 举报

版主

版主

精华贴数
3
技术积分
9663
社区积分
197
注册时间
2001-10-9
论坛徽章:
23
ITPUB元老
日期:2005-02-28 12:57:002011新春纪念徽章
日期:2011-01-25 15:41:012011新春纪念徽章
日期:2011-01-25 15:41:502011新春纪念徽章
日期:2011-01-25 15:42:152011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:562011新春纪念徽章
日期:2011-02-18 11:43:33ITPUB年度最佳技术回答奖
日期:2011-04-08 18:37:39现任管理团队成员
日期:2011-05-07 01:45:08ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412011新春纪念徽章
日期:2011-01-04 10:24:02ITPUB9周年纪念徽章
日期:2010-10-08 09:28:51
发表于 2006-7-25 12:29:09 |显示全部楼层
最初由 wing hong 发布
[B]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 [/B]


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

使用道具 举报

相关内容推荐
您需要登录后才可以回帖 登录 | 注册

TOP技术积分榜 社区积分榜 徽章 电子杂志 团队 统计 邮箱 虎吧 老博客 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档 | IT博客
CopyRight 1999-2011 itpub.net All Right Reserved. 北京皓辰网域网络信息技术有限公司版权所有 联系我们 网站律师 隐私政策 知识产权声明
京ICP证:060528号 北京市公安局海淀分局网监中心备案编号:1101082001 广播电视节目制作经营许可证:编号(京)字第1149号
  
回顶部