因此空间索引的分析不能采用analyze的方式,必须采用dbms_stats包的过程进行分析才有效果。
user_indexes该视图中的last_analyzed来源于sys.ind$中的analyzetime。
空间索引的分析:采用的空间索引为INDEX_I_EXCH_S_SPATIAL
1)查询索引最近一次分析的时间
select a.index_name,a.last_analyzed from user_indexes a where index_name='INDEX_I_EXCH_S_SPATIAL';
INDEX_NAME LAST_ANALYZED
------------------------------ -----------------
INDEX_I_EXCH_S_SPATIAL 2011-8-11 13:10:11
2)执行ANALYZE分析
ANALYZE INDEX index_i_exch_s_spatial COMPUTE STATISTICS;
3)再次查询最近一次分析时间
select a.index_name,a.last_analyzed from user_indexes a where index_name='INDEX_I_EXCH_S_SPATIAL';
INDEX_NAME LAST_ANALYZED
------------------------------ -----------------
INDEX_I_EXCH_S_SPATIAL 2011-8-11 13:10:11
4)执行如下分析后,分析时间发生改变:
BEGIN dbms_stats.gather_index_stats('ltwebgis','INDEX_I_EXCH_S_SPATIAL'); END;
select a.index_name,a.last_analyzed from user_indexes a where index_name='INDEX_I_EXCH_S_SPATIAL';
INDEX_NAME LAST_ANALYZED
------------------------------ -----------------
INDEX_I_EXCH_S_SPATIAL 2011-8-11 13:15:33
一般索引的分析:采用的索引为IDX_I_EXCH_S_FID
1)查询索引最近一次分析的时间
select a.index_name,a.last_analyzed from user_indexes a where index_name='IDX_I_EXCH_S_FID';
INDEX_NAME LAST_ANALYZED
------------------------------ -----------------
INDEX_I_EXCH_S_SPATIAL 2011-8-11 13:08:55
2)执行ANALYZE分析
ANALYZE INDEX idx_i_exch_s_fid COMPUTE STATISTICS;
3)再查询最近分析时间
select a.index_name,a.last_analyzed from user_indexes a where index_name='IDX_I_EXCH_S_FID';
INDEX_NAME LAST_ANALYZED
------------------------------ -----------------
INDEX_I_EXCH_S_SPATIAL 2011-8-11 13:19:14
4)执行如下分析后,分析时间也发生改变:
BEGIN dbms_stats.gather_index_stats('ltwebgis','IDX_I_EXCH_S_FID'); END;
select a.index_name,a.last_analyzed from user_indexes a where index_name='IDX_I_EXCH_S_FID';
INDEX_NAME LAST_ANALYZED
------------------------------ -----------------
INDEX_I_EXCH_S_SPATIAL 2011-8-11 13:19:53
查询最近一次重建的时间
select object_name,last_ddl_time from user_objects where object_type='INDEX' AND object_name='INDEX_I_EXCH_S_SPATIAL';
OBJECT_NAME LAST_DDL_TIME
----------------------- ----------------
INDEX_I_EXCH_S_SPATIAL 2011-8-1 16:26:11
对该索引重建后,last_ddl_time时间发生变化
ALTER INDEX INDEX_I_EXCH_S_SPATIAL REBUILD;
select object_name,last_ddl_time from user_objects where object_type='INDEX' AND object_name='INDEX_I_EXCH_S_SPATIAL';
OBJECT_NAME LAST_DDL_TIME
----------------------- ----------------
INDEX_I_EXCH_S_SPATIAL 2011-8-11 10:50:45