get materialized view state, unknown state - oracle

good morning friends,
How can I know if a materialized view was updated correctly.
The refresh methods that I am using in the views are: complete, fast and forced.
I am currently using the state of the view to identify if it updated correctly, but it is causing me problems.
code:
SELECT OWNER,MVIEW_NAME,AFTER_FAST_REFRESH, STALENESS, COMPILE_STATE FROM DBA_MVIEWS
It appears to me that it needs to compile or unknown status (column: COMPILE_STATE), I was investigating and there are several reasons why it may appear as unknown, what other alternative do I have to obtain the update status of the view or what could I do?
I will appreciate any help.
Thank you,
Greetings.

You can use also DBA_MVIEW_REFRESH_TIMES: https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/DBA_MVIEW_REFRESH_TIMES.html
DBA_MVIEW_REFRESH_TIMES describes refresh times of all materialized views in the database.
and DBA_REGISTERED_MVIEWS
DBA_REGISTERED_MVIEWS describes all registered materialized views (registered at a master site or a master materialized view site) in the database. Its columns are the same as those in ALL_REGISTERED_MVIEWS.

Related

How can i find the size of a materialized view log in oracle?

I need to find the mview log size to drop those logs and also the status of the mview to know if it is active or not. help me to find these details.
Depending on your user privileges, the DBA_MVIEW_REFRESH_TIMES or ALL_MVIEW_REFRESH_TIMES dictionary views will tell you when a materialized view was last refreshed.
The ALL_MVIEW_LOGS or DBA_MVIEW_LOGS views will give you information about the logs themselves, including their underlying tables, and the ALL_REGISTERED_MVIEWS or DBA_REGISTERED_MVIEWS views will tell you which materialized views are known and whether they are capable of using the MV Logs.
An MV Log should automatically purge itself up to the current point in time when all registered materialized views have completed their refreshes.

When does data in Oracle materialized view actually change?

I have an Oracle materialized view refreshed on demand. Since the view is pretty large, it takes a while to update. I am wondering: when do the updates really become visible to the queries that try read the view? Does RDBMS update the view in a buffer and then makes it visible when update is complete? Or will the changes gradually become visible to the reader? Is this possible to control this?
Materialized views can be refreshed on commit or on demand.
Oracle's documentation is quite good
https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_6002.htm#i2116410
To have materialized views refresh incrementally you must use the FAST option and you must have materialized view logs to capture changes on the source tables.
If you schedule the demanded refreshes frequently there will be less work to be done for each refresh. If you schedule them less frequently there will be more work to be done. You need to investigate how changes on the source tables are distributed over time to choose well.
Changes will be visible to users when the refresh (whatever size) commits.

Is there any advantages related to Performance in Oracle View

I'm learning about Oracle Views and I got the concept of views but little confused about performance.
I was watching video and there I listen that oracle view can increase the performance. Suppose I have created view like below.
CREATE VIEW SALES_MAN
AS
SELECT * FROM EMP WHERE JOB='SALESMAN';
Ok now I have executed query to get SALES_MAN detail.
SELECT * FROM SALES_MAN
Ok now confusion start.
I listened in video that once the above query SELECT * FROM SALES_MAN will be executed the DATA/RECORD will be placed into cache memory after hitting the oracle DB. and if I will execute same query( IN Current Session/Login ) Oracle Engine will not hit to Database and will give you record from CACHED-MEMORY is it right?
But I have read on many websites that View add nothing to SQL performance more
Another Reference that says view not help in performance. Here
So Views increase performance too or not?
A view is just a kind of virtual table defined by a query. It has no proper data and performance will depend on the underlying table(s) and the query definition.
But you also have Materialized View wich stores the results from the view query definition. Data is synchronized automatically, and you can add indexes to the view. In this case, you can achieve better performances. The cost to pay is
more space (the view contains data dupplicated),
no access to the up to date data from the underlying tables
You (and perhaps the creator of the un-cited video) are confusing two different concepts. The reason the data that was in the cache was used on the second execution was NOT because it was the second execution of the view. As long as data remains in the cache, it is available for ANY query that needs it. The very fact that the first execution of the view had to get the data from disk should be a strong clue. And what if your second use of the view wasn't until hours or days later when the data was no longer in the cache? The answer remains. A view does NOT improve performance.

which is better to use a view or a materialised view?

So I have a process to design where there are few base tables on which I have to create a view and from that view I will extract and derive data and insert into an another table.
we would use this last table for extracting reports
This process will run daily, since the data on the base tables have updates have everyday.
he whole purpose of this process is to make things "faster" for reporting,
So my concern here is with using the view. I am wondering if a materialized view would be better to use here in terms of performance instead the view or view itself would be the better.
Has anyone had to deal with such situation and found an approach that performs well and works efficiently??
Any leads on this would be highly appreciated

How to create a hierarchical query as a materilized view with refresh on commit in oracle

Could anyone please tell me if there is a possibility to create a hierarchical query in oracle 10g as a materialized view with REFRESH ON COMMIT?
I tried using CONNECT_BY but this doesn't work with REFRESH ON COMMIT.
Are there any other possibilities to get the view automatically refreshed when the underlying data changes?
Or may be there is an alternative to CONNECT_BY which works with REFRESH ON COMMIT?
Thanks in advance for any hints or help.
I really doubt that you'll be able to get this functionality. I think that the best you can hope for is to be able to define a materialized view that optimises the hierarchical query, for example by basing the MV on an underlying table that is actually index-organised or hash clustered on the parent_id column.

Resources