启用几何实体化视图的快速刷新

Enabling fast refresh on materialized view with geometry

我有一个看似简单的问题,material化视图似乎是理想的解决方案,但我没有让它有效地工作,也许答案很简单:"Oracle does not allow it at all" ,但我希望我忽略了一些愚蠢的事情。

问题:由于一些历史决定,我有一个 table 包含来自两个国家的几何图形,存储在一个国家的坐标系中。我现在想使用共享坐标系创建 material 化视图。所以实际上,实现此目的的最简单查询是:

select thr_ident, thr_status, geom from 
  ((
     select thr_ident, thr_status, sdo_cs.transform(sdo_cs.transform(thr_geometry, 327680), 8307) as geom
     from th_threat 
     where thr_origin in (6,61, 11, 9) 
   ) 
   union all 
   (
     select thr_ident, thr_status, sdo_cs.transform(thr_geometry, 8307) as geom
     from th_threat 
     where thr_origin not in (6,61,11,9) 
  ))

几何只创建一次,但我想保持状态同步(出于可视化目的)。所以我在 thr_identthr_status:

上添加了一个 materialized 视图日志
create materialized view log on th_threat 
with sequence, rowid (thr_ident, thr_status)
including new values;

并创建了 material 化视图,并希望它在原始源数据发生更改时自动保持同步 ('on commit')。

但显然 refresh on commit 在使用对象时是不可能的,但是 fast refresh 就足够接近了,如果 efficient/fast 就足够了。

我假设假设 union all 并没有真正帮助,我将其重写为一个查询如下:

create materialized view th_threat_mv 
--  refresh fast on demand
as  
select 
  rowid rid, thr_ident, thr_status, 
  case 
    when thr_origin in (6,61, 11, 9) then 
      sdo_cs.transform(sdo_cs.transform(thr_geometry, 327680), 8307)
    else   
      sdo_cs.transform(thr_geometry, 8307)
  end as geom    
from th_threat; 

但仍然没有启用快速刷新。

explain_mview的结果显示只有完全刷新是可能的,其他的都被禁用了(对我来说有点难read/deduce,如果需要我可以转储它,但它重复了三个次 object data types are not supported in this context).

mtune_view 给我以下错误:

QSM-03113: Cannot tune the MATERIALIZED VIEW statement

QSM-02083: mv references PL/SQL function that maintains state

所以现在我猜这是由 SDO_CS.TRANSFORM 引起的?

理论上我假设快速刷新是 possible/simple:

但要么我没有正确实现它,要么 Oracle 无法推断它实际上是一个简单的 1-1 material 化视图(因为它包含几何图形?案例陈述?)。

我总是可以使用触发器来构建我自己的解决方案,但我想知道我是否忽略了一些明显的东西来让 material 视图有效地工作(因为它看起来非常合适)。非常感谢任何 help/insights/comments。

你是对的。 Oracle 认为这是一个复杂的查询,因为几何函数和快速刷新在复杂查询上是不可能的。 您将需要进行全面刷新。 谢谢

萨比哈