楼主: dba_mx

函数索引 + HIDDEN_COLUMN

[复制链接]
论坛徽章:
131
2006年度最佳技术回答
日期:2007-01-24 12:58:48福特
日期:2013-10-24 13:57:422014年新春福章
日期:2014-02-18 16:41:11马上有车
日期:2014-02-18 16:41:11马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上加薪
日期:2014-02-19 11:55:142013年新春福章
日期:2013-02-25 14:51:24
11#
发表于 2006-6-26 10:49 | 只看该作者
可以再trace 一下 create function index的过程。

完了,给你加精华吧……

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
12#
发表于 2006-6-26 12:37 | 只看该作者
最初由 dba_mx 发布
[B]于是,随之而来的问题就是Oracle是如何维护这个隐藏字段的呢?

我希望通过trace来查看:

[php]
SQL> ALTER SESSION SET SQL_TRACE=TRUE;
...
郁闷的是,在trace文件中根本就没有维护那个隐藏字段的操作,或者说此操作被Oracle特意过滤了? [/B]


I don't think there's any way to see any recursive SQL Oracle runs to maintain the hidden columns during a DML. In fact, Oracle probably doesn't even consider that as a separate recursive SQL.

I thought there was some event we can set to trace FBI's operation. But I didn't find any.

Yong Huang

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
13#
发表于 2006-6-27 05:53 | 只看该作者
最初由 Yong Huang 发布
[B]

I don't think there's any way to see any recursive SQL Oracle runs to maintain the hidden columns during a DML. In fact, Oracle probably doesn't even consider that as a separate recursive SQL.

I thought there was some event we can set to trace FBI's operation. But I didn't find any.

Yong Huang [/B]


On second thought, I don't think Oracle should have any separate, additional, recursive SQL to handle FBI. The reason is simple. Once you have a FBI, a hidden column is added to the table. It's no different than you explicitly add a column with a weird name like SYS_NC00002$ and set the default value to yourfunction(originalcolumn), except desc won't show it. In fact, you can't run this any more

alter table test.tt add (SYS_NC00002$ varchar2(10));

You would get an error saying the column already exists.

Anyway, suppose everything is like you explicitly add a new column (so desc mytable shows it), setting default to function(original_column). When you update mytable set original='xxx', the new column will be automatically updated. There's no other hidden SQLs you would see maintaining the new column.

Yong Huang

使用道具 举报

回复
论坛徽章:
131
2006年度最佳技术回答
日期:2007-01-24 12:58:48福特
日期:2013-10-24 13:57:422014年新春福章
日期:2014-02-18 16:41:11马上有车
日期:2014-02-18 16:41:11马上有车
日期:2014-02-19 11:55:14马上有房
日期:2014-02-19 11:55:14马上有钱
日期:2014-02-19 11:55:14马上有对象
日期:2014-02-19 11:55:14马上加薪
日期:2014-02-19 11:55:142013年新春福章
日期:2013-02-25 14:51:24
14#
发表于 2006-6-27 12:45 | 只看该作者
But how this happend:
When you update mytable set original='xxx', the new column will be automatically updated ?

使用道具 举报

回复
论坛徽章:
3
数据库板块每日发贴之星
日期:2006-02-18 01:02:33会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44
15#
 楼主| 发表于 2006-6-27 13:29 | 只看该作者

创建函数索引的TRACE

[php]

CREATE TABLE TEST.TT (STR VARCHAR2(5));
INSERT INTO TEST.TT SELECT 'TTT' || LPAD(ROWNUM,2,'0') FROM DUAL CONNECT BY ROWNUM<=5;
COMMIT;
ALTER SESSION SET SQL_TRACE=TRUE;
CREATE INDEX TEST.FIDX_TT_STR ON TEST.TT(SUBSTR(STR,4));
ALTER SESSION SET SQL_TRACE=FALSE;
..
[/php]

从trace文件中根本看不到向表中添加隐藏字段的步骤,或者说我没有看出来。

vila_ora_1864.rar

7.86 KB, 下载次数: 17

使用道具 举报

回复
论坛徽章:
3
数据库板块每日发贴之星
日期:2006-02-18 01:02:33会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44
16#
 楼主| 发表于 2006-6-27 13:31 | 只看该作者
我觉得,Oracle对于函数索引所引发的 隐藏字段及其后续的维护操作都做了过滤,
就如同 DESC 里面看不到那个字段一样,其添加、更新的过程也看不到

使用道具 举报

回复
论坛徽章:
42
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:022011新春纪念徽章
日期:2011-01-25 15:42:332011新春纪念徽章
日期:2011-01-25 15:42:56管理团队成员
日期:2011-05-07 01:45:08ITPUB十周年纪念徽章
日期:2011-11-01 16:20:282012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:232012新春纪念徽章
日期:2012-02-13 15:09:23
17#
发表于 2006-6-27 20:19 | 只看该作者
we should check the segcol#, if it's 0 then oracle will not store the computed value.

使用道具 举报

回复
论坛徽章:
47
蒙奇·D·路飞
日期:2017-03-27 08:04:23马上有车
日期:2014-02-18 16:41:112014年新春福章
日期:2014-02-18 16:41:11一汽
日期:2013-09-01 20:46:27复活蛋
日期:2013-03-13 07:55:232013年新春福章
日期:2013-02-25 14:51:24ITPUB 11周年纪念徽章
日期:2012-10-09 18:03:322012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20
18#
发表于 2006-6-28 02:26 | 只看该作者

Re: 创建函数索引的TRACE

最初由 dba_mx 发布
[B][php]

CREATE TABLE TEST.TT (STR VARCHAR2(5));
INSERT INTO TEST.TT SELECT 'TTT' || LPAD(ROWNUM,2,'0') FROM DUAL CONNECT BY ROWNUM<=5;
COMMIT;
ALTER SESSION SET SQL_TRACE=TRUE;
CREATE INDEX TEST.FIDX_TT_STR ON TEST.TT(SUBSTR(STR,4));
ALTER SESSION SET SQL_TRACE=FALSE;
..
[/php]

从trace文件中根本看不到向表中添加隐藏字段的步骤,或者说我没有看出来。 [/B]


Earlier you said the hidden *update* on the hidden column is not shown. I said there *isn't* any need to have a separate SQL to update that. Now you say the hidden column *creation* is not shown.

I didn't read your trace file since I don't have WinRar installed on this computer. But you can clearly see the 向表中添加隐藏字段的步骤. Here's my test, done on 10.1.0.3.1 (but likely to be reproducible on 9i).

alter system flush shared_pool;
alter session set events = '10046 trace name context forever, level 4';
create index fbi_testfbi on testfbi (upper(name));

I use 10046 event level 4 just to see the bind value. Here's the trace file:

insert into col$(obj#,name,intcol#,segcol#,type#,length,precision#,scale,null$,offset,fixedstorage,segcollength,deflength,default$,col#,property,charsetid,charsetform,spare1,spare2,spare3)values(:1,:2,:3,:4,:5,:6,decode(:7,0,null,:7),decode(:5,2,decode(:8,-127/*MAXSB1MINAL*/,null,:8),178,:8,179,:8,180,:8,181,:8,182,:8,183,:8,231,:8,null),:9,0,:10,:11,decode(:12,0,null,:12),:13,:14,:15,:16,:17,:18,:19,:20)
END OF STMT
PARSE #10:c=15625,e=5765,p=0,cr=84,cu=0,mis=1,r=0,dep=1,og=4,tim=1227079990
BINDS #10:
bind 0: dty=2 mxl=22(22) mal=00 scl=00 pre=00 oacflg=08 oacfl2=0001 size=24 offset=0
   bfp=05c206f4 bln=22 avl=04 flg=05
   value=68541
bind 1: dty=1 mxl=32(12) mal=00 scl=00 pre=00 oacflg=18 oacfl2=0001 size=32 offset=0
   bfp=28d47a1e bln=32 avl=12 flg=09
   value="SYS_NC00002$"
...

It's about adding a column, with obj# bound at runtime to 68541 and name to "SYS_NC00002$"... Isn't that clear?

I flush shared pool just to show recursive SQLs. Otherwise since dictionary cache already has some data dictionary info, some recursive SQLs wouldn't be run. But in this case, it's a DML against a data dictionary table. This flush may not be necessary.

Yong Huang

使用道具 举报

回复
论坛徽章:
3
数据库板块每日发贴之星
日期:2006-02-18 01:02:33会员2007贡献徽章
日期:2007-09-26 18:42:10ITPUB新首页上线纪念徽章
日期:2007-10-20 08:38:44
19#
 楼主| 发表于 2006-7-18 11:08 | 只看该作者
alter session set events = '10046 trace name context forever, level 4';
关键在这一句,我只是普通的一个trace而已,没有设置10046事件,所以没有看到。。。。 呵呵,才疏学浅啊

使用道具 举报

回复
论坛徽章:
86
ITPUB元老
日期:2005-02-28 12:57:002012新春纪念徽章
日期:2012-01-04 11:49:542012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:202012新春纪念徽章
日期:2012-02-13 15:13:20咸鸭蛋
日期:2012-05-08 10:27:19版主8段
日期:2012-05-15 15:24:112013年新春福章
日期:2013-02-25 14:51:24
20#
发表于 2006-7-18 13:19 | 只看该作者
首先我并不认为oracle会在  表的block中去真实地存储 函数计算出来的 值,这么一个 列 应该仅仅是一个虚拟的,作为某种用途的列。

真实的数据应该是在函数索引的segment中。 所以不存在DML 时候递归  DML 维护表数据的问题。

使用道具 举报

回复

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

本版积分规则 发表回复

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