Nested Materialized Views: Creation / Refresh Overview and ORA-12053

Doc ID: Note:212553.1 Type: BULLETIN
Last Revision Date: 13-NOV-2002 Status: PUBLISHED


PURPOSE
-------

To explain in details how to fast refresh a Nested Materialized View.


SCOPE & APPLICATION
-------------------

This bulletin is intended for DW developers and administrators as well as
support analysts.

Nested Materialized Views
-------------------------

The rapid increase of DW complexity has introduced the need to further
enhance the materialized views flexibility and functionality. A nested
materialized view is simply a materialized view that is based on another
materialized view, this allows more complex queries against the base
materialized view itself to be handled in the fastest response time.

While Nested materialized views have achieved the fastest possible response
time for complex DW queries, we still have restrictions with populating them.
Complete refresh works fine with nested materialized views but it is not
always acceptable especially in Tera byte DW environments, so the question
here ; can we fast refresh Nested materialized views and how?

Fast Refresh Guidelines
------------------------
In order to be able to fast refresh a nested materialized view it has to be
setup according to the following rules:

a) Use Rowid MV logs
b) Nested MV must be a combination of a join view and a single-table aggregate
c) Define a single-table aggregate materialized view on top of a materialized
join view
d) Nested materialized view cannot be a parent and a grandparent of some
table/object in the dependency tree.

Failing to meet any of the above conditions will result with ORA-12053 when
creating the nested materialized view:

Error: ORA-12053 (ORA-12053)
Text: This is not a valid nested materialized view


Troubleshooting Ora-12053
-------------------------
ORA-12053 is sometimes misleading because it has many causes , so even if you
get this error your MV still can be a valid one and fast refreshed as well if
you follow the 4 rules listed above.

The following example was tested in both 8.1.7 & 9.2 databases using Scott
demo tables:

SQL> desc emp
Name Null? Type
----------------------------------------- -------- --------------------------
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)

SQL> desc dept
Name Null? Type
----------------------------------------- -------- --------------------------
DEPTNO NOT NULL NUMBER(2)
DNAME VARCHAR2(14)
LOC VARCHAR2(13)

SQL> create materialized view log on emp with primary key,rowid;

Materialized view log created.

SQL> create materialized view log on dept with primary key,rowid;

Materialized view log created.
-- create the first MV as join MV, Rowid columns were added to enable
-- fast refresh on a join view...
SQL> create materialized view empmv1
refresh fast on demand
with primary key
as select e.empno,d.deptno,e.ename,d.dname, e.rowid erowid,d.rowid drowid
from emp e, dept d
where e.deptno=d.deptno
/
Materialized view created.

SQL> alter table empmv1 add primary key(empno);

Materialized view altered.

-- create materialized view log for the empmv1:
sql> create materialized view log on empmv1 with primary key,
rowid(deptno)
including new values;

-- now create the nested materialized view empmv2:

SQL> create materialized view empmv2
refresh fast on demand
with primary key
as select empno,deptno
from empmv1
/
from empmv1
*
ERROR at line 5:
ORA-12053: this is not a valid nested materialized view

-- we are missing one rule here , empmv2 has to be a single-table aggregate..

SQL> create materialized view empmv2
refresh fast on demand
with primary key
as select empno,deptno , count(*)
from empmv1
group by empno,deptno
/

Materialized view created.

9.2 Nested Materialized Views Enhancement
------------------------------------------
In Oracle 9.2 we are able to use any combination of single-table aggregates
and join views , in other words rule C above is waved.

Working Example:

-- create demo tables in Scott schema in 9.2 database and run the following ..

SQL> alter table emp add primary key(empno);

Table altered.

SQL> alter table dept add primary key(deptno);

Table altered.

SQL> create materialized view log on dept
with primary key,
rowid(dname)
including new values;

Materialized view log created.

SQL> create materialized view log on emp
with primary key,
rowid(deptno,sal)
including new values;

Materialized view log created.

SQL> create materialized view deptmv1
refresh fast on demand
with primary key
as select empno,deptno , count(sal) cnt_sal from emp
group by empno,deptno
/

Materialized view created.

SQL> alter table deptmv1 add primary key(empno);

Table altered.

SQL> create materialized view log on deptmv1 with primary key,
rowid(deptno,cnt_sal) including new values
/

Materialized view log created.

SQL> create materialized view deptmv2
refresh fast on demand
with primary key
as select empno,cnt_sal,dname,e.rowid erowid,d.rowid drowid
from deptmv1 e, dept d
where e.deptno=d.deptno
/

Materialized view created.

-- While running the above example in 8.1.7 database or 9.0.1 database will
-- result with ora-12053: this is not a valid nested materialized view .


Restrictions When Using Nested Materialized Views
--------------------------------------------------

1. Nested materialized views has to be explicitly refreshed . For example you
need to explicitly refresh Empmv1 first then Empmv2.
2. Fast refresh for ON COMMIT is not supported for a higher-level
materialized view that contains joins and aggregates.

RELATED DOCUMENTS
-----------------

Oracle8i Data Warehousing Guide.
Oracle9i Data warehousing Guide , release 9.2

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/193161/viewspace-50261/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/193161/viewspace-50261/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by com.alipay.sofa.jraft.util.internal.UnsafeUtil (jar:file:/E:/service/nacos-server-2.2.3/nacos/target/nacos-server.jar!/BOOT-INF/lib/jraft-core-1.3.12.jar!/) to field java.nio.Buffer.address WARNING: Please consider reporting this to the maintainers of com.alipay.sofa.jraft.util.internal.UnsafeUtil WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release 2023-07-15 22:58:51,129 WARN Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'instanceOperatorClientImpl' defined in URL [jar:file:/E:/service/nacos-server-2.2.3/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-naming-2.2.3.jar!/com/alibaba/nacos/naming/core/InstanceOperatorClientImpl.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'clientOperationServiceProxy' defined in URL [jar:file:/E:/service/nacos-server-2.2.3/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-naming-2.2.3.jar!/com/alibaba/nacos/naming/core/v2/service/ClientOperationServiceProxy.class]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'persistentClientOperationServiceImpl' defined in URL [jar:file:/E:/service/nacos-server-2.2.3/nacos/target/nacos-server.jar!/BOOT-INF/lib/nacos-naming-2.2.3.jar!/com/alibaba/nacos/naming/core/v2/service/impl/PersistentClientOperationServiceImpl.class]: Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.alibaba.nacos.naming.core.v2.service.impl.PersistentClientOperationServiceImpl]: Constructor threw exception; nested exception is java.lang.UnsatisfiedLinkError: C:\Users\Administrator\AppData\Local\Temp\librocksdbjni15037951375079649142.dll: %
07-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值