暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle 物化视图

ASKTOM 2020-08-12
204

问题描述

嗨,汤姆,

这是参考先前关于MV的问题。我不知道如何针对所提出的问题编写revert。

https://asktom.oracle.com/pls/apex/asktom.search?tag=materialized-view-complete-refresh-getting-slower

实际上,在下面的pr_fact_x中是一个视图,而day_pr_mst_x又是一个MV,这是重建的,这意味着每天都要完全刷新,因此无法快速刷新。

create materialized view pr_month nologging
tablespace idm_msta_ts
using index tablespace idm_msta_is
as
   select -- + index_ffs(d) use_hash(d f)
         f.client_id,
         f.account_dim_id,
         f.org_dim_dc_id,
         f.org_dim_unit_id,
         f.instill_product_dim_id,
         f.instill_product_id,
         f.client_product_dim_id,
         d.month_period_num,
         sum(f.fact_delivered_cost) as TOTAL_COST,
         sum(f.fact_delivered_cases) as TOTAL_CASES ,
         sum(f.fact_delivered_weight) as TOTAL_WEIGHT,
         sum(f.fact_delivered_volume)  as TOTAL_VOLUME,
         sum(f.fact_delivered_count) as TOTAL_COUNT,
         f.currency_dim_id as CURRENCY_DIM_ID
  from   pr_fact_x f,
         day_pr_mst_x d
  where  f.client_id            = d.client_id
  and    f.invoice_trx_date = d.calendar_date
  group by f.client_id,
         f.account_dim_id,
         f.org_dim_dc_id,
         f.org_dim_unit_id,
         f.instill_product_dim_id,
         f.instill_product_id,
         f.client_product_dim_id,
         d.month_period_num ,
         f.currency_dim_id  ;
复制


请建议。

专家解答

Actually in below pr_fact_x is a view and day_pr_mst_x is again a MV which is rebuild means complete refresh every day so fast refresh is not possible.

您可以制作一个查询视图的MV,并在提交时快速刷新另一个MV。如果您在以下位置创建了物化视图日志:

-视图中的所有表格
-您查询的MV (day_pr_mst_x)

从理论上讲,这是可行的。视图查询的性质可能意味着快速刷新是不可能的,但是要回答我需要查看视图定义!

同样,如果你正在寻找帮助优化查询的完整刷新,我需要这样看看执行计划,你通过运行:

set serveroutput off
select /*+ gather_plan_statistics */ from 
select * 
from   table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
复制


https://blogs.oracle.com/sql/how-to-create-an-execution-plan

因此,无论哪种方式,我们都需要更多详细信息来帮助您!
文章转载自ASKTOM,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论