简体   繁体   English

Oracle物化视图计算成本

[英]Oracle materialized view computational cost

Is the computational cost of updating a stored procedure materialized view , in Oracle, based on the query execution or the result set? 在Oracle中基于查询执行或结果集更新存储过程的 实现的计算成本是物化视图吗? More specifically, does Oracle store the results of the query in such a way that contributes significantly to the time required to refresh the view? 更具体地说,Oracle是否以这种方式大大节省了刷新视图所需的时间来存储查询结果?

Of course, queries which take very long to execute as well as incredibly large or small result sets make this impossible to answer ubiquitously. 当然,执行时间非常长的查询以及结果集的大小令人难以置信,使得这无处不在。

The question is more about how the view actually stores the result set (in memory, on disk) so I can think about how frequently to rebuild materialized views. 问题更多是关于视图实际上如何存储结果集(在内存中,在磁盘上)的信息,因此我可以考虑重建实例化视图的频率。

Materialized view is basically a table combined with an algorithm to update it. 物化视图基本上是一个表,结合有算法对其进行更新。

01:37:23 HR@sandbox> create materialized view mv_dual as select dummy from dual;

Materialized view created.

Elapsed: 00:00:00.52
01:37:56 HR@sandbox> select object_name, object_type from user_objects where object_name = 'MV_DUAL';

OBJECT_NAME     OBJECT_TYPE
--------------- -------------------
MV_DUAL         TABLE
MV_DUAL         MATERIALIZED VIEW

Elapsed: 00:00:00.01

You can also create materialized views on prebuilt tables. 您还可以在预建表上创建实例化视图。

If we talk about refresh - there are two options: fast refresh and complete refresh. 如果我们谈论刷新-有两种选择:快速刷新和完全刷新。

Complete refresh just re-executes MV query, while fast refresh performs incremental updates. 完全刷新仅重新执行MV查询,而快速刷新则执行增量更新。

http://docs.oracle.com/cd/E16338_01/server.112/e10706/repmview.htm#i29858 http://docs.oracle.com/cd/E16338_01/server.112/e10706/repmview.htm#i29858

there are two types of mviews 有两种类型的mview

Complete refresh mview - the entier mview will be rebuild every refresh. 完成刷新mview-整个mview将在每次刷新时重建。 similar to delete and insert (notice: if you specify atomic = F or have version < 9 it will be truncate / insert append). 类似于删除和插入(注意:如果您指定atomic = F或版本小于9,将被截断/插入附加)。

Fast refresh mview - oracle will create a table to store incremental changes. 快速刷新mview-oracle将创建一个表来存储增量更改。 when refreshing, the changes stored in the side table will be applied to the mview. 刷新时,存储在边表中的更改将应用​​于mview。

fast refresh is faster on refresh but slows down dml operations on the base table. 快速刷新在刷新时更快,但是会减慢基表上的dml操作。

when you consider your refresh strategy you should consider how much changes are applied to the base table and how often you need to refresh the mview. 在考虑刷新策略时,应考虑对基表进行了多少更改以及需要多长时间刷新一次mview。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM