Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Materialized View Log for Multiple Materialized Views

Posted on 2013-01-09
6
Medium Priority
?
732 Views
Last Modified: 2013-01-11
Environment:
HPUX 11.11
Oracle 9.2.0.7

I don't have a lot of experience using Materialized Views so I'd like some clarification if possible.

I have a couple of Views that users use heavily that represent self joining a table to itself from 6 to 10 times.

When called in a query, these views are adding some considerable overhead to the query run time.

Based on the answer to a previous question, I'm looking to turn them into Materialized Views.

Because they would be MV's based upon a self join, they are not considered "simple" MV's and can't be used for FAST REFRESH.  

Can multiple MV's be kept updated from a single MV Log ?  Will Oracle keep the updates in sync in multiple target MV's that are not simple and have to do a complete refresh ?

In the Oracle documentation (here), under the Managing Materialized View Log Space header, it talks about " multiple simple materialized views".

Since my MV's aren't "simple", is there anything I need to be aware of ?

I don't *think* there's going to be a concern, but would like to be sure before I try to implement.

Anyone have any experience with this kind of thing ?

Thanks in advance for any insight.
0
Comment
Question by:Steve Wales
  • 3
  • 2
6 Comments
 
LVL 16

Expert Comment

by:Wasim Akram Shaik
ID: 38761688
instead of creating multiple simple materialized views, create  a materialized view log for each mv ... this will make the mv refresh to check out their independent logs while refreshing..

mv log is specified at the time of creation of mv

for ex:

CREATE MATERIALIZED VIEW LOG ON emp WITH ROWID (dept_id, emp_id, ename,startdate) INCLUDING NEW VALUES;
0
 
LVL 35

Expert Comment

by:johnsone
ID: 38762944
Materialized view logs are not used for complete refreshes.  They are only used for fast refreshes.  Since your views are not "simple" and require a complete refresh every time, there is no need to create the materialized view log.
0
 
LVL 23

Author Comment

by:Steve Wales
ID: 38763204
There's no way to tell the materialized view to not refresh unless there has a been a change to the underlying data when using a complex MV ?

The structure I'm dealing with doesn't change very often.  It seems like such a waste to rebuild the complete structure every hour when it might only change once a quarter if that.

My last part to this question, then, is what happens if a query attempts to execute against the MV while a rebuild is in progress (or vice versa, a rebuild starts while a query is running)?

I'm hoping that it will just hold a lock while the first process does it's thing and the second process to start will wait until the first operation completes and then complete successfully.
0
 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

 
LVL 35

Accepted Solution

by:
johnsone earned 2000 total points
ID: 38763281
This may have changed in 11 as I have not checked yet, but on a complete refresh, while the refresh is in process the table will appear empty to all users.  The reason is that the first thing a refresh of a complex materialized view does is truncate the table.

What I have seen done if you want it to always be accessible is to actually have 2 materialized views and a synonym.  The synonym points to the current materialized view.  You refresh the other view and once it completes successfully change the synonym to the one that just refreshed.  Users access the synonym and the fact that there is 2 views is hidden to them.
0
 
LVL 23

Author Comment

by:Steve Wales
ID: 38763354
OK maybe I can look at it that way.  It doesn't take long for the refresh to complete, a matter of a few seconds, but because of Murphy's Law, you know that the users will want to query it in that short window.

Would need to modify the job that does the refresh to play synonym dancing, but that's doable.

I'll play with it and get back to you.  Thanks.
0
 
LVL 23

Author Closing Comment

by:Steve Wales
ID: 38769363
Thanks.  This is how they want to proceed, so we'll go that way.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question