Oracle中是否可以部分刷新物化视图?
我有一个非常复杂的 Oracle 视图,基于其他物化视图、常规视图以及一些表(我无法“快速刷新”它)。大多数时候,此视图中的现有记录基于日期并且是“稳定的”,新记录集具有新日期。
有时,我会收到回溯日期。我知道这些是什么以及如果我维护一张桌子如何处理它们,但我想保留这是一个“视图”。完整刷新大约需要 30 分钟,但对于任何给定日期只需要 25 秒。
我可以指定仅应更新物化视图的一部分(即受影响的日期)吗?
我是否必须废弃视图并使用表和过程来填充或刷新该表中的给定日期?
I have a very complex Oracle view based on other materialized views, regular views as well as some tables (I can't "fast refresh" it). Most of the time, existing records in this view are based on a date and are "stable", with new record sets having new dates.
Occasionally, I receive back-dates. I know what those are and how to deal with them if I were maintaining a table, but I would like to keep this a "view". A complete refresh would take around 30 minutes, but it only takes 25 seconds for any given date.
Can I specify that only a portion of a materialized view should be updated (i.e. the affected dates)?
Do I have to scrap the view and use a table and a procedure to populate or refresh a given date in that table?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
按日期分区,如答案 3 (skaffman) 所示。
您可以只刷新普通 mv(下面的
table_refreshed
),然后使用交换关键字,即Partition by date as in answer 3 (skaffman).
You could just do the refresh of a normal mv(
table_refreshed
below) and than use the exchange keyword i.e.经过更多阅读和判断这个问题缺乏答案,我得出的结论是不可能刷新物化视图的单个分区。
如果您能给出一个语法示例来证明事实并非如此,我会很乐意将您的答案标记为已接受的答案。
对于将来可能会发现此问题有用的其他人:您可能还想知道在 Oracle 10g 中,刷新分区(或任何 mview)将导致 Oracle 发出
DELETE
,然后发出插入
。如果这给你带来了性能问题(像我一样),可以选择使用atomic_refresh => false,这将
截断
,然后INSERT /*+APPEND*/
。After more reading and judging by the lack of answers to this question, I come come to the conclusion that it is not possible to refresh a single partition of a materialized view.
If you can give a syntax example that proves otherwise, I will happily mark your answer the accepted one.
To others who might find this questions useful in the future: you might also want to know that in Oracle 10g, refreshing a partition (or any mview) will cause Oracle to issue
DELETE
, followed byINSERT
.If this is giving you performance problems (like me), there is an option to use
atomic_refresh => false
, which willTRUNCATE
, thenINSERT /*+APPEND*/
.我已经能够通过分区更改跟踪刷新物化视图的单个分区。
似乎要求使用
REFRESH FAST WITH ROWID
选项创建视图,并使用'P'
方法调用DBMS_MVIEW.REFRESH
。I have been able to refresh a single partition of a materialized view with partition change tracking.
It seems to require that the view is created with
REFRESH FAST WITH ROWID
option andDBMS_MVIEW.REFRESH
is called with'P'
method.您可以像对普通表一样对物化视图进行分区。按日期对 mview 进行分区,然后您可以仅刷新所需的分区。
You can partition materialized views just as you can with normal tables. Partition your mview by date, and then you can refresh only the required partition.