Oracle中是否可以部分刷新物化视图?

发布于 2024-08-12 07:32:26 字数 267 浏览 8 评论 0原文

我有一个非常复杂的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

终陌 2024-08-19 07:32:26

按日期分区,如答案 3 (skaffman) 所示。

您可以只刷新普通 mv(下面的table_refreshed),然后使用交换关键字,即

ALTER TABLE all_partitions
  EXCHANGE PARTITION to_calculate
  WITH TABLE table_refreshed
  WITHOUT VALIDATION
  UPDATE GLOBAL INDEXES;

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.

ALTER TABLE all_partitions
  EXCHANGE PARTITION to_calculate
  WITH TABLE table_refreshed
  WITHOUT VALIDATION
  UPDATE GLOBAL INDEXES;
傻比既视感 2024-08-19 07:32:26

经过更多阅读和判断这个问题缺乏答案,我得出的结论是不可能刷新物化视图的单个分区。

如果您能给出一个语法示例来证明事实并非如此,我会很乐意将您的答案标记为已接受的答案。

对于将来可能会发现此问题有用的其他人:您可能还想知道在 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 by INSERT.

If this is giving you performance problems (like me), there is an option to use atomic_refresh => false, which will TRUNCATE, then INSERT /*+APPEND*/.

请叫√我孤独 2024-08-19 07:32:26

我已经能够通过分区更改跟踪刷新物化视图的单个分区。

似乎要求使用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 and DBMS_MVIEW.REFRESH is called with 'P' method.

不羁少年 2024-08-19 07:32:26

您可以像对普通表一样对物化视图进行分区。按日期对 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文