Default behavior of create & rebuild index in 10G (zt)
very different from 9i
In oracle 10G, when create index or rebuild index, statistics will be computed automatically.
Here is my experiment:
C:>sqlplus sys/oracle as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 5月 30 18:26:48 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select * from v$version;
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
SQL> conn wwf/wwf
Connected.
SQL> select * from tab;
SQL> create table tt as select * from all_objects;
Table Created
SQL> create index ind_tt on tt(object_id);
Index Created
SQL> alter session set nls_date_format = 'yyyy-mm-dd hh24:mi:ss';
Session altered
SQL> select index_name, last_analyzed, blevel, num_rows, distinct_keys from user_indexes
2 where index_name = 'IND_TT';
INDEX_NAME LAST_ANALYSED BLEVEL NUM_ROWS DISTINCT_KEYS
------------------------------ ------------------- ---------- ---------- -------------
IND_TT 2007-05-30 18:28:18 1 40809 40809
SQL> delete from tt where object_id < 20000;
14147 rows deleted
SQL> commit;
Committed
SQL> alter index ind_tt rebuild;
Index created
SQL> select index_name, last_analyzed, blevel, num_rows, distinct_keys from user_indexes
2 where index_name = 'IND_TT';
INDEX_NAME LAST_ANALYSED BLEVEL NUM_ROWS DISTINCT_KEYS
------------------------------ ------------------- ---------- ---------- -------------
IND_TT 2007-05-30 18:32:28 1 26662 26662
It seems that we have no way to prevent Oracle computing statistics.
Here is what I got from oracle official document():
COMPUTE STATISTICS In earlier releases, you could use this clause to start or stop the collection of statistics on an index. This clause has been deprecated. Oracle Database now automatically collects statistics during index creation and rebuild. This clause is supported for backward compatibility and will not cause errors.
There is one way to disable this behavior(http://download-west.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_stats.htm#i1043993):
When statistics on a table are locked, all the statistics depending on the table, including table statistics, column statistics, histograms and statistics on all dependent indexes, are considered to be locked.
This is my experiment:
SQL> drop index ind_tt;
Index Dropped
SQL> exec dbms_stats.lock_table_stats(user, 'TT');
PL/SQL executed successfully。
SQL> create index ind_tt on tt(object_id);
Index created
SQL> select index_name, last_analyzed, blevel, num_rows, distinct_keys from user_indexes
2 where index_name = 'IND_TT';
INDEX_NAME LAST_ANALYZED BLEVEL NUM_ROWS DISTINCT_KEYS
------------------------------ ------------------- ---------- ---------- -------------
IND_TT
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/35489/viewspace-84791/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 加快create / rebuild index的3個點(zt)RebuildIndex
- create index , rebuild index troubleshooting 索引故障解決IndexRebuild索引
- create index online 與rebuild index onlineIndexRebuild
- create index online 與rebuild index onlineIndexRebuild
- 加快建立索引(create / rebuild index) 的幾點索引RebuildIndex
- 【江楓 】Oracle 9i和10g在create index和rebuild index的統計資訊的區別OracleIndexRebuild
- alter index ... rebuild online的機制(zt)IndexRebuild
- rebuild indexRebuildIndex
- index rebuildIndexRebuild
- Oracle create/rebuild index開並行時要記得noparallel哦~OracleRebuildIndex並行Parallel
- rebuild index 排序RebuildIndex排序
- sybase rebuild indexRebuildIndex
- Index rebuild --case 1IndexRebuild
- alter index rebuild 與 rebuild onlineIndexRebuild
- alter index rebuild與index_statsIndexRebuild
- rebuild index online和create index online及沒有online的區別RebuildIndex
- Oracle 10g rebuild index,索引原來統計資訊丟失Oracle 10gRebuildIndex索引
- create index/create index online區別Index
- ORACLE中index的rebuildOracleIndexRebuild
- Index Online RebuildIndexRebuild
- 【羅玄】從鎖的角度看rebuild index online和rebuild indexRebuildIndex
- 聊聊索引Index Rebuild和Rebuild Online(下)索引IndexRebuild
- 聊聊索引Index Rebuild和Rebuild Online(上)索引IndexRebuild
- CREATE BITMAP INDEXIndex
- alter index ind1 rebuild 和alter index ind1 rebuild onlineIndexRebuild
- Oracle alter index rebuild 說明OracleIndexRebuild
- alter index rebuild和rebuild online的區別IndexRebuild
- rebuild index 和 recreate index (重新建立index) 的區別RebuildIndex
- create index online 和create index 不同及注意點Index
- 索引是如何定期rebuild的(zt)索引Rebuild
- hive orc表'orc.create.index'='true'與'orc.create.index'='false'HiveIndexFalse
- create index .. onlineIndex
- Unable to create git index lockGitIndex
- create index onlineIndex
- Create Index ...ONLINEIndex
- index rebuild online的問題IndexRebuild
- 大資料量rebuild index的經歷大資料RebuildIndex
- zt_oracle indexOracleIndex