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.

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 'EastRiver' 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...