Oracle - 在完全刷新期间仍然可以访问物化视图。这是如何运作的?

发布于 2024-11-29 02:47:34 字数 222 浏览 1 评论 0原文

在我们的一个应用程序中,我们有一个巨大的物化视图,每天刷新 3 次,刷新需要 7 个小时。 (我知道这并不理想)。这让我很困惑,因为我确实认为用户和会话在刷新时无法访问此物化视图,但显然他们可以! (刷新的类型是完整刷新)

根据我的理解,在完全刷新期间,现有数据集将被删除,然后重新执行查询。如果这是真的,那么在刷新物化视图时用户/其他会话如何能够访问物化视图

In one of our applications, we have a massive Materialized View that refreshes three times a day, and takes seven hours to refresh. (Not ideal, I know). This perplexed me, because I surely thought that users and sessions could not access this materialized view while it was being refreshed, but apparently they can!. (The type of refresh is a complete refresh)

During a complete refresh, to my understanding, the existing dataset is dropped and the query is then re-executed. If this is true, then how are users/other sessions able to access the materialized view while the materialized view is being refreshed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

机场等船 2024-12-06 02:47:34

完全刷新可以通过两种不同的方式进行——原子刷新或非原子刷新。原子刷新只需发出 DELETE 来删除物化视图中的所有行,然后执行 INSERT 来插入新数据。这一切都在单个事务中进行,因此 Oracle 标准的多版本读取一致性架构允许 Oracle 向其他会话显示旧数据,直到刷新完成。在非原子刷新中,Oracle 对物化视图执行 TRUNCATE,然后执行直接路径 INSERT 来插入新数据。这实际上更有效,但由于 TRUNCATE 是 DDL,这意味着旧数据在刷新期间对其他会话不可见。

There are two different ways that a complete refresh can happen-- an atomic refresh or a non-atomic refresh. An atomic refresh simply issues a DELETE to delete all the rows in the materialized view and then does an INSERT to insert the new data. This is all within a single transaction so Oracle's standard multi-version read consistency architecture lets Oracle show other sessions the old data until the refresh completes. In a non-atomic refresh, Oracle does a TRUNCATE on the materialized view and then a direct-path INSERT to insert the new data. This is substantially more efficient but since TRUNCATE is DDL, it means that the old data is not visible to other sessions during the refresh.

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