Author: Don Burleson
Page:
1
2
3
Materialized views are amongst the most significant SQL tuning tools that allow you to pre-join complex views and pre-compute summaries for super-fast response time. Although they are complex still they play an important role in reducing repetitive I/O. In this article I will give some effective tips for materialized views.
Materialized views in Oracle:
- Materialized views were first introduced in Oracle8.
- Materialized views were enhanced in Oracle9 i to allow very fast dynamic creation of complex objects.
- Materialized views allow sub-second response times by pre-computing aggregate information and Oracle9 i dynamically rewrites SQL queries to reference existing materialized views.
- Without materialized views many unnecessary repeating large-table full-table scans are seen as summaries are computed, over and over.
Using materialized views:
Special initialization parameters must be set and special authority must be granted to the users of materialized views in order to use them.
Below code shows how to set initialization parameters within Oracle to enable the mechanisms for materialized views and query rewrite.
optimizer_mode = choose, first_rows, or all_rows
job_queue_interval = 3600
job_queue_processes = 1
query_rewrite_enabled = true
query_rewrite_integrity = enforced
compatible = 8.1.5.0.0 (or greater)
query_rewrite_integrity:
If the CURSOR_SHARING parameter is set to FORCE, some rewrites that were text-match based in 8.1.5 may no longer be possible with 8.1.6. There are three acceptable values for query_rewrite_integrity
trusted |
Assumes that the materialized view is current |
enforced (default) |
Always goes to materialized view with fresh data |
stale_tolerated |
Uses materialized view with both stale and fresh data |
System privileges:
You must grant several system privileges to all users who will be using the materialized views. In many cases, the Oracle DBA will encapsulate these grant statements into a single role and grant the role to the end users:
grant query rewrite to scott;
grant create materialized view to scott;
alter session set query_rewrite_enabled = true;
Page:
1
2
3
More Oracle Articles, Database Articles and DBA Tips
Database Security: Step by step guideline
Beware of WHEN OTHERS THEN NULL, Important Concerns!!
Secrets of Resources with AWR Reports, Great!!
Web Applications: Oracle-SQL Database Security
Efficient Oracle Migration, Amazing Tricks!
|