oracle-databaseoptimizationquery-optimizationmaterialized-views

Oracle materialized view computational cost


Is the computational cost of updating a stored procedure materialized view, in Oracle, based on the query execution or the result set? More specifically, does Oracle store the results of the query in such a way that contributes significantly to the time required to refresh the view?

Of course, queries which take very long to execute as well as incredibly large or small result sets make this impossible to answer ubiquitously.

The question is more about how the view actually stores the result set (in memory, on disk) so I can think about how frequently to rebuild materialized views.


Solution

  • there are two types of mviews

    Complete refresh mview - the entier mview will be rebuild every refresh. similar to delete and insert (notice: if you specify atomic = F or have version < 9 it will be truncate / insert append).

    Fast refresh mview - oracle will create a table to store incremental changes. when refreshing, the changes stored in the side table will be applied to the mview.

    fast refresh is faster on refresh but slows down dml operations on the base table.

    when you consider your refresh strategy you should consider how much changes are applied to the base table and how often you need to refresh the mview.