|
测试了一晚上,下面是脚本:- drop table test1;
- drop index ind_test1_col1_unq;
- drop index ind_test1_col2_rev;
- drop index ind_test1_col3;
- drop index ind_test1_col4;
- drop index index ind_test1_col5;
- drop index ind_test1_col567;
- drop index ind_test1_func;
- drop table test1;
- create table test1(col1 number(10),col2 number(10),col3 number(10),
- col4 number(10),col5 varchar2(20),col6 varchar2(20),
- col7 varchar2(30),col8 varchar2(30),col9 varchar2(50));
- insert into test1(col1,col2,col3,col4,col5,col6,col7,col8,col9)
- select rownum*7+1,rownum*3+1,rownum*5+1,trunc(dbms_random.value(1,10000)),
- owner,object_type,object_name,to_char(timestamp),
- dbms_random.string('p',trunc(dbms_random.value(1,50)))
- from all_objects;
- commit;
- --分别验证唯一索引、反转索引、非唯一索引、位图索引、降序索引(多列)、函数索引
- create unique index ind_test1_col1_unq on test1(col1);
- create unique index ind_test1_col2_rev on test1(col2) reverse;
- create index ind_test1_col3 on test1(col3);
- create index ind_test1_col4 on test1(col4);
- create bitmap index ind_test1_col5 on test1(col5);
- create index ind_test1_col567 on test1(col5 asc,col6 desc,col7 desc);
- create index ind_test1_func on test1(to_number(substr(col8,1,4)||substr(col8,6,2)||substr(col8,9,2)));
复制代码 环境信息如下:
1、oracle参数。
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_block_size integer 8192
2、建测试数据后采集统计信息。
begin
dbms_stats.gather_table_stats(user,'TEST1',estimate_percent=>100,
method_opt=>'for all indexed columns',cascade=>true);
end;
3、索引统计信息
INDEX_NAME BLEVEL NUM_ROWS DISTINCT_KEYS CLUSTERING_FACTOR
------------------------------ ---------- ---------- ------------- -----------------
IND_TEST1_COL1_UNQ 1 74204 74204 1123
IND_TEST1_COL2_REV 1 74204 74204 74203
IND_TEST1_COL3 1 74204 74204 1123
IND_TEST1_COL4 1 74204 9994 73984
IND_TEST1_COL5 1 37 33 37
IND_TEST1_COL567 2 74204 73861 51242
IND_TEST1_FUNC 1 74204 47 1191
4、索引统计信息
SEGMENT_NAME BLOCKS
-------------------- ----------
IND_TEST1_FUNC 192
IND_TEST1_COL567 576
IND_TEST1_COL5 64
IND_TEST1_COL4 192
IND_TEST1_COL2_REV 192
IND_TEST1_COL3 192
IND_TEST1_COL1_UNQ 192 |
|