Oracle - 使用 DBMS_MVIEW.REFRESH 刷新“REFRESH FORCE ON DEMAND”视图时会发生什么

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6349274/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 03:21:00  来源:igfitidea点击:

Oracle - What happens when refreshing a 'REFRESH FORCE ON DEMAND' view with DBMS_MVIEW.REFRESH

oracleoracle10gmaterialized-views

提问by contactmatt

I have the following materialized view -

我有以下物化视图 -

CREATE MATERIALIZED VIEW TESTRESULT 
ON PREBUILT TABLE WITH REDUCED PRECISION
REFRESH FORCE ON DEMAND
WITH PRIMARY KEY
AS 
SELECT...
FROM...
WHERE...

This materialized view has no backing MATERIALIZED VIEW LOG. As seen in the clause above this MV has "ON DEMAND" specifies, and according to Oracle documentation,

这个实体化视图没有支持实体化视图日志。如上面的条款所示,该 MV 具有“ON DEMAND”指定,并且根据 Oracle 文档,

"[ON DEMAND] indicate[s] that the materialized view will be refreshed on demand by calling one of the three DBMS_MVIEW refresh procedures."

“[ON DEMAND] 指示[s] 将通过调用三个 DBMS_MVIEW 刷新过程之一按需刷新物化视图。”

When I call DBMS_MVIEW.REFRESH('TESTRESULT') , what is occuring? Is it manually checking each record to see if it has been updated?

当我调用 DBMS_MVIEW.REFRESH('TESTRESULT') 时,发生了什么?是否手动检查每条记录以查看是否已更新?

Oracle Version: 10g

甲骨文版本:10g

回答by Justin Cave

By default (and this default changes in different versions of Oracle), that will do a full, atomic refresh on the materialized view. That means that the data in the materialized view will be deleted, the underlying query will be re-executed, and the results will be loaded into the materialized view. You can make the refresh more efficient by passing in a value of FALSE for the ATOMIC_REFRESHparameter, i.e.

默认情况下(在不同版本的 Oracle 中此默认更改),这将对物化视图进行完整的原子刷新。这意味着将删除物化视图中的数据,重新执行底层查询,并将结果加载到物化视图中。您可以通过为ATOMIC_REFRESH参数传入 FALSE 值来提高刷新效率,即

dbms_mview.refresh( 'TESTRESULT', atomic_refresh => false );

That will cause the materialized view to be truncated, the query re-executed, and the results inserted into the materialized view via a direct path insert. That will be more efficient than an atomic refresh but the materialized view will be empty during the refresh.

这将导致实体化视图被截断,查询重新执行,结果通过直接路径插入插入到实体化视图中。这将比原子刷新更有效,但物化视图在刷新期间将为空。