我创建一个如下所示的视图:
create view join_tabs as ( select col_x as col_z from tab_a union select col_y as col_z from tab_b );
如果我执行以下操作:
select * from join_tabs where col_z = 'BLAH';
如果tab_a索引col_x和tab_b索引col_y,我们应该可以通过两次索引搜索来实现.
但是,如果我可以在一个索引中的两个表上创建一个索引,或者甚至以视图的索引方式,如果源表(tab_a或tab_b)发生更改,则可以立即自动更新.
有没有办法在Oracle中做到这一点?
解决方法
选择物化视图的索引
The two most common operations on a
materialized view are query execution
and fast refresh,and each operation
has different performance
requirements. Query execution might
need to access any subset of the
materialized view key columns,and
might need to join and aggregate over
a subset of those columns.
Consequently,query execution usually
performs best if a single-column
bitmap index is defined on each
materialized view key column.In the case of materialized views
containing only joins using fast
refresh,Oracle recommends that
indexes be created on the columns that
contain the rowids to improve the
performance of the refresh operation.If a materialized view using aggregates is fast refreshable,then an index is automatically created unless USING NO INDEX is specified in the CREATE MATERIALIZED VIEW statement.