ITPUB??ì3
12月微软Hyper-V虚拟化沙龙主题征集
ITPUB论坛 » Oracle专题深入讨论 » 关于materialized view的数据更新性能

标题: 关于materialized view的数据更新性能
离线 zhyuh
中级会员


精华贴数 2
个人空间 0
技术积分 3021 (509)
社区积分 488 (1468)
注册日期 2001-9-26
论坛徽章:5
ITPUB元老参与2007年甲骨文全球大会(中国上海)纪念ITPUB北京香山2007年会纪念徽章会员2006贡献徽章授权会员 
      

发表于 2004-12-1 15:48 
关于materialized view的数据更新性能

关于materialized view有几个问题不太清楚,

1。materialized view的更新方式主要有COMPLETE和FAST(即incremental )两种,FAST的后台机制是什么?oracle依据什么判断数据是新还是旧的呢?

2。如果采用FORCE方式更新,在基表里也需要建materialized view log吗?

3。on commit和on demand两种数据更新模式哪一种会获得比较高的性能? 有什么办法可以提高materialized view的数据更新性能?

请各位高手不吝指点,或者给一点详细的文档也行。
谢谢先!


__________________
i have a good job and hope to have a great career,   i have a nice girl friend and hope to have a great marriage,   i have a wonderful parents and hope to be a good parent too,   i have a rented house and i hope to have a home of my own,   i travel in taxi and i hope to have and drive my own car,   i wonder when i have all i want .........what's next in my needs list,   i wonder when i have all i want..........will i still be a happy man in the world,   i wonder when i have all i want..........will this world be still a  happy place to live in....?[url]blog.itpub.net/zhyuh[/url]
只看该作者    顶部
离线 xzh2000
仙人抚我须 结发授长生



精华贴数 13
个人空间 0
技术积分 46551 (14)
社区积分 5188 (293)
注册日期 2002-7-17
论坛徽章:32
现任管理团队成员ITPUB元老授权会员2008北京奥运纪念徽章:篮球2008北京奥运纪念徽章:垒球生肖徽章2007版:狗
2008北京奥运纪念徽章:柔道2008北京奥运纪念徽章:帆船生肖徽章2007版:虎ITPUB新首页上线纪念徽章数据库板块每日发贴之星数据库板块每日发贴之星

发表于 2004-12-1 18:15 
Re: 关于materialized view的数据更新性能



QUOTE:
最初由 zhyuh 发布
关于materialized view有几个问题不太清楚,

1。materialized view的更新方式主要有COMPLETE和FAST(即incremental )两种,FAST的后台机制是什么?oracle依据什么判断数据是新还是旧的呢?

2。如果采用FORCE方式更新,在基表里也需要建materialized view log吗?

3。on commit和on demand两种数据更新模式哪一种会获得比较高的性能? 有什么办法可以提高materialized view的数据更新性能?

请各位高手不吝指点,或者给一点详细的文档也行。
谢谢先!


1
complete就是delete from mv_..然后insert ....
fast是merge into....
这个你应该可以通过10046 event跟踪到的
2
当然,最好是创建mv log,这样在force刷新时可以使用fast的方式
3 on commit是实时刷新,性能较差点
on damend用dbms_mview.refresh+job定时刷新,性能较高
但on damend将不能使用query rewrite,如果数据不是要求很
实时的话,用on dament会更好一些的。


__________________
过目即忘  插柳成荫
只看该作者    顶部
离线 zhyuh
中级会员


精华贴数 2
个人空间 0
技术积分 3021 (509)
社区积分 488 (1468)
注册日期 2001-9-26
论坛徽章:5
ITPUB元老参与2007年甲骨文全球大会(中国上海)纪念ITPUB北京香山2007年会纪念徽章会员2006贡献徽章授权会员 
      

发表于 2004-12-1 21:26 
xzh2000

谢谢!

我自己也看了一下,materialized view log里面应该纪录了一些DML信息,force(incremental)应该是依据这些信息决定哪些纪录需要refresh,然后从基表检索更新所涉及的纪录。(你说的merge into好像跟incremental差不多抽象哦

另外on demand 和 query rewrite 互斥的说法我没有找到出处,请明示。

oracle文档种关于query rewrite的restrictions说法:
You should keep in mind the following restrictions:

The defining query of the materialized view cannot contain any non-repeatable expressions (ROWNUM, SYSDATE, non-repeatable PL/SQL functions, and so on).
The query cannot contain any references to RAW or LONG RAW datatypes or object REFs.
If the defining query of the materialized view contains set operators (UNION, MINUS, and so on), rewrite will use them for full text match rewrite only.
If the materialized view was registered as PREBUILT, the precision of the columns must agree with the precision of the corresponding SELECT expressions unless overridden by the WITH REDUCED PRECISION clause.
If the materialized view contains the same table more than once, it is possible to do a general rewrite, provided the query has the same aliases for the duplicate tables as the materialized view.
General Query Rewrite Restrictions

You should keep in mind the following restrictions:

If a query has both local and remote tables, only local tables will be considered for potential rewrite.
Neither the detail tables nor the materialized view can be owned by SYS.
SELECT and GROUP BY lists, if present, must be the same in the query of the materialized view.
Aggregate functions must occur only as the outermost part of the expression. That is, aggregates such as AVG(AVG(x)) or AVG(x)+ AVG(x) are not allowed.
CONNECT BY clauses are not allowed.


__________________
i have a good job and hope to have a great career,   i have a nice girl friend and hope to have a great marriage,   i have a wonderful parents and hope to be a good parent too,   i have a rented house and i hope to have a home of my own,   i travel in taxi and i hope to have and drive my own car,   i wonder when i have all i want .........what's next in my needs list,   i wonder when i have all i want..........will i still be a happy man in the world,   i wonder when i have all i want..........will this world be still a  happy place to live in....?[url]blog.itpub.net/zhyuh[/url]
只看该作者    顶部
离线 xzh2000
仙人抚我须 结发授长生



精华贴数 13
个人空间 0
技术积分 46551 (14)
社区积分 5188 (293)
注册日期 2002-7-17
论坛徽章:32
现任管理团队成员ITPUB元老授权会员2008北京奥运纪念徽章:篮球2008北京奥运纪念徽章:垒球生肖徽章2007版:狗
2008北京奥运纪念徽章:柔道2008北京奥运纪念徽章:帆船生肖徽章2007版:虎ITPUB新首页上线纪念徽章数据库板块每日发贴之星数据库板块每日发贴之星

发表于 2004-12-2 08:48 
force首先判断能否进行fast刷新,如果条件不具备,
就采用complete刷新。

如果数据的变更很少(INSERT/DELETE/UPDATE)的话,
那更适合用on damend进行控制刷新的时间。

通常情况下,MV的query rewrite要求从mview中获得的结果
集与通过扫描基表是一致的,如果用on dament刷新的话,
很多情况下它们应该是不一致的,因为on dament是定时的
刷新,所以想使用query rewrite的话,最好使用on commit;


__________________
过目即忘  插柳成荫
只看该作者    顶部
离线 zhyuh
中级会员


精华贴数 2
个人空间 0
技术积分 3021 (509)
社区积分 488 (1468)
注册日期 2001-9-26
论坛徽章:5
ITPUB元老参与2007年甲骨文全球大会(中国上海)纪念ITPUB北京香山2007年会纪念徽章会员2006贡献徽章授权会员 
      

发表于 2004-12-2 22:23 
嗯,谢谢!

我得再看看文档,看看query rewrite的要求条件


__________________
i have a good job and hope to have a great career,   i have a nice girl friend and hope to have a great marriage,   i have a wonderful parents and hope to be a good parent too,   i have a rented house and i hope to have a home of my own,   i travel in taxi and i hope to have and drive my own car,   i wonder when i have all i want .........what's next in my needs list,   i wonder when i have all i want..........will i still be a happy man in the world,   i wonder when i have all i want..........will this world be still a  happy place to live in....?[url]blog.itpub.net/zhyuh[/url]
只看该作者    顶部
在线/呼叫 husthxd
版主


精华贴数 8
个人空间 1288
技术积分 61239 (9)
社区积分 3829 (374)
注册日期 2002-2-20
论坛徽章:109
现任管理团队成员ITPUB元老ITPUB北京九华山庄2008年会纪念徽章第18届世界杯(德国)纪念徽章管理团队2006纪念徽章会员2007贡献徽章
会员2006贡献徽章玉石琵琶九尾狐狸紫蜘蛛蓝色妖姬红孩儿

发表于 2004-12-3 09:08 
Re: Re: 关于materialized view的数据更新性能



QUOTE:
最初由 xzh2000 发布


1
complete就是delete from mv_..然后insert ....
fast是merge into....
这个你应该可以通过10046 event跟踪到的
2
当然,最好是创建mv log,这样在force刷新时可以使用fast的方式
3 on commit是实时刷新,性能较差点
on damend用dbms_mview.refresh+job定时刷新,性能较高
但on damend将不能使用query rewrite,如果数据不是要求很
实时的话,用on dament会更好一些的。


1.如果物化视图刷新组中一个物化视图的话,会用truncate table而不是delete清楚物化视图的数据.
3.设置on commit有很多限制的.比如必须有count(*)等.


__________________
少吃饭,多吃菜少说话,多做事少灌水,多看文档
-----------------------吃遍全城!--------------------
-----------------------Java钻研中--------------------
--------------------学好英语,报效祖国--------------------
人生最幸福的事情莫过于通过自己的努力实现自己的梦想!
http://space.itpub.net/6906/
只看该作者    顶部
离线 xzh2000
仙人抚我须 结发授长生



精华贴数 13
个人空间 0
技术积分 46551 (14)
社区积分 5188 (293)
注册日期 2002-7-17
论坛徽章:32
现任管理团队成员ITPUB元老授权会员2008北京奥运纪念徽章:篮球2008北京奥运纪念徽章:垒球生肖徽章2007版:狗
2008北京奥运纪念徽章:柔道2008北京奥运纪念徽章:帆船生肖徽章2007版:虎ITPUB新首页上线纪念徽章数据库板块每日发贴之星数据库板块每日发贴之星

发表于 2004-12-3 09:11 
Re: Re: Re: 关于materialized view的数据更新性能



QUOTE:
最初由 husthxd 发布


1.如果物化视图刷新组中一个物化视图的话,会用truncate table而不是delete清楚物化视图的数据.
3.设置on commit有很多限制的.比如必须有count(*)等.


1 这个倒没能注意到。
2 不必的,偶创建的mv有一些是on commit的,但没有含count(*).




__________________
过目即忘  插柳成荫
只看该作者    顶部
 
    

相关内容


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