I have materialized view for which i want to alter its refresh time:
REFRESH FORCE START WITH SYSDATE NEXT SYSDATE +1 DISABLE QUERY REWRITE
I want to know few things in this.
- What does NEXT SYSDATE +1 depicts (how i am going to change it)
- What is DISABLE QUERY REWRITE
In other words DISABLE QUERY REWRITE vs ENABLE QUERY REWRITE with respect to materialized view.
Materialized Views in oracle support a feature called Query Rewriting. This means that the database can analyse a particular query to the base tables, decide whether the same results would be returned from the materialized view, and query the MV instead of the base tables. This can be quite a good optimisation in some cases. Telling oracle to disable query rewrites means to forego this potential optimisation, and always query the base tables even if a query to the MV would return the same data.
Example would be:
Then executing a query:
The query engine could take the regular select statement above, and retrieve the data directly from the materialized view, without having to do a potentially expensive join (since the join is already done by the MV). This is query rewriting.
This question describes what the
with sysdate nextclause does. Apparently, it tells the database that the next refresh date is going to be in 1 day (sysdate +1).