微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/mssql/79156.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐