ITPUB??ì3
2010数据库技术大会
ITPUB论坛 » Oracle专题深入讨论 » truncate 实现机制


您有 1 条公共消息
  • 来自: 公共消息 标题: 3-5月ITPUB数据库 ... 内容: ITPUB与3月和5月分别安排了Oracle 11g DBA和Oracle性能优化培训,以及 ...

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


    精华贴数 0
    个人空间 0
    技术积分 6800 (246)
    社区积分 15 (10600)
    注册日期 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
    技术积分 6800 (246)
    社区积分 15 (10600)
    注册日期 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
    技术积分 6800 (246)
    社区积分 15 (10600)
    注册日期 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
    人生就是如此



    精华贴数 39
    个人空间 0
    技术积分 112692 (4)
    社区积分 12111 (165)
    注册日期 2001-12-12
    论坛徽章:55
    现任管理团队成员ITPUB元老年度论坛发贴之星年度论坛发贴之星ITPUB北京2009年会纪念徽章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 不一样了,于是返回错误。错误编号我忘记了。


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


    精华贴数 0
    个人空间 0
    技术积分 6800 (246)
    社区积分 15 (10600)
    注册日期 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
    技术积分 1448 (1470)
    社区积分 9 (13815)
    注册日期 2002-8-7
    论坛徽章:5
    管理团队成员管理团队2006纪念徽章会员2006贡献徽章2010新春纪念徽章2009日食纪念 
          

    发表于 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
    技术积分 1448 (1470)
    社区积分 9 (13815)
    注册日期 2002-8-7
    论坛徽章:5
    管理团队成员管理团队2006纪念徽章会员2006贡献徽章2010新春纪念徽章2009日食纪念 
          

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


    只看该作者    顶部
    在线/呼叫 wing hong
    版主



    精华贴数 0
    个人空间 0
    技术积分 1448 (1470)
    社区积分 9 (13815)
    注册日期 2002-8-7
    论坛徽章:5
    管理团队成员管理团队2006纪念徽章会员2006贡献徽章2010新春纪念徽章2009日食纪念 
          

    发表于 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
    版主



    精华贴数 3
    个人空间 0
    技术积分 6547 (256)
    社区积分 192 (2991)
    注册日期 2001-10-9
    论坛徽章:12
    现任管理团队成员ITPUB元老管理团队2006纪念徽章会员2006贡献徽章授权会员2010新春纪念徽章
    2010新春纪念徽章祖国60周年纪念徽章ITPUB8周年纪念徽章2009日食纪念2009新春纪念徽章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
    版主



    精华贴数 3
    个人空间 0
    技术积分 6547 (256)
    社区积分 192 (2991)
    注册日期 2001-10-9
    论坛徽章:12
    现任管理团队成员ITPUB元老管理团队2006纪念徽章会员2006贡献徽章授权会员2010新春纪念徽章
    2010新春纪念徽章祖国60周年纪念徽章ITPUB8周年纪念徽章2009日食纪念2009新春纪念徽章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证:060528号 联系我们