sql – 索引索引(Oracle)

前端之家收集整理的这篇文章主要介绍了sql – 索引索引(Oracle)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
让我说我有两个表,tab_a和tab_b.

我创建一个如下所示的视图:

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中做到这一点?

解决方法

我与Oracle不符,但我相信 Materialized Views这样做.

选择物化视图的索引

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.

原文链接:https://www.f2er.com/mssql/79156.html

猜你在找的MsSQL相关文章