I have a view that collects data from several tables. While there are no indexes on the view itself anything that uses the view seems to benefit from the underlying tables having indexes. Are these being used automatically? If they are then what is the point of creating indexes on your views? Any recommended articles on this subject would be welcomed.
Indexes can only be created on views which have the same owner as the referenced table or tables. This is also called an intact ownership-chain between the view and the table(s). Typically, when table and view reside within the same schema, the same schema-owner applies to all objects within the schema.
Indexed views improve the performance of queries that use joins and aggregations in processing huge amount of data and are executed very frequently. The environments that are best suited to indexed views are data warehouses and the Online Analytical Processing (OLAP) databases.
The indexes on the base table are still used whenever you access the view. You don't need to use an indexed view, unless the view contains an expensive logic (aggregations or joins) that you don't want to perform each time you query the view.
Oracle SQL standards do not support creating indexes on views. If you need to index documents whose contents are in different tables, you can create a data storage preference using the USER_DATASTORE object.
Yes, the underlying table indexes are used automatically - a view just pulls the data from the underlying tables after all.
With regards to the benefits of creating indexes on a view, see this MS Technet article. Small excerpt:
Using indexes to improve query performance is not a new concept; however, indexed views provide additional performance benefits that cannot be achieved using standard indexes. Indexed views can increase query performance in the following ways:
- Aggregations can be precomputed and stored in the index to minimize expensive computations during query execution.
- Tables can be prejoined and the resulting data set stored.
- Combinations of joins or aggregations can be stored.
The query optimizer rewrites the query and "flattens" the use of sub-queries (which a view really is). So underlying indexes will be used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With