加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MsSql教程 > 正文

sql – 索引索引(Oracle)

发布时间:2020-12-12 06:23:42 所属栏目:MsSql教程 来源:网络整理
导读:让我说我有两个表,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索引co
让我说我有两个表,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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读