前缀 local partition index 和非前缀 local partition index
只是想知道原理。假设我有张表t1, 栏位(a,b,c,d),那现在这张表创建分区,分区键(a).如果我现在要查询 where d=xxxx.
问题:
我可以建立
create index idx_1 on t1(a,d) local;
or
create index idx_2 on t1(d) local;
1,我这个查询中走那个索引较快?
2,我测试的结果和是idx_2 速度快?感觉有点不太可能
3,无法那种,他都是要PARTITION RANGE ALL,才能再找到数据,他不能快速定位是那个分区么? 如果where只有一个d=***
觉得建立一个字段d的全局索引比较好。 为啥一个字段的要好,说明原因呀! 还是没有回复呢?老大帮忙看看 1.
视乎具体的SQL语句, 不能一概而论
例如 如果你要 select a,d from tab 那么显然 前者好于后者
2.
没有办法快速定位 索引分区, 多个 分区 就等于多个 索引树 都需要去遍历 , 这是 LOCAL index固有的特点 非前缀索引的情况下,查询条件中包含分区键和索引列,但是执行集合中未对该分区索引进行裁剪。参考脚本如下:
-- 1. create table
create table t1 ( a int, b varchar2(300),c int) partition by range(a)
(
partition p01 values less than (1000),
partition p02 values less than (2000),
partition p03 values less than (3000),
partition p04 values less than (4000),
partition p05 values less than (5000),
partition p06 values less than (6000),
partition p07 values less than (7000),
partition p08 values less than (8000),
partition p09 values less than (9000),
partition p10 values less than (10000),
partition p11 values less than (11000),
partition p12 values less than (12000),
partition p13 values less than (13000),
partition p14 values less than (14000),
partition p15 values less than (15000),
partition p16 values less than (16000),
partition p17 values less than (17000),
partition p18 values less than (18000),
partition p19 values less than (19000),
partition p20 values less than (20000)
)
--2. populate testing data
insert into t1 select rownum,lpad('x',200,'x') from dual connect by rownum<20000;
commit
--copy
insert /*+ append */ into t1 select * from t1;
commit
insert /*+ append */ into t1 select * from t1;
commit
insert /*+ append */ into t1 select * from t1;
commit
insert /*+ append */ into t1 select * from t1;
commit
update t1 set c= MOD(a,7)*a;
commit
--3. create index
create index t1_idx on t1(c) local;
drop index t1_idx;
--create index t1_idxa_c on t1(a,c) local;
--drop index t1_idxa_c
--create index t1_idx_c_a on t1(c,a) local;
--drop index t1_idx_c_a
--4. query
select c from t1 where c >100 and c<1000 and a >=15000 and a<16000
select * from t1 where c >100 and c<1000 and a >=15000 and a<16000
欢迎指点。
页:
[1]