日期:2014-05-16  浏览次数:20445 次

ORACLE 管理索引

index: independent physical structure,pointer(book catalog,point to table data--rowid)
--speed query /overload data update.
--OLTP: less indexes
--OLAP: more indexes
--b-tree 平衡二叉树,nonleaf,leaf,只有两级。
types of index:
logical: single column与并连index;
unique index与nonunique;
function-based index;
domain index
physical: partitioned or nonpartitioned index
b-tree (normal or reverse key) 最长用的。leaf 全是pointer
bitmap
b-tree: index entry header:key column length:key column value:...:rowid 取值唯一性高,其效率越高。
适用范围:取值唯一性高,更新代价比较低,用or选项很低,用于OLTP.
create index xxx on table(column) tablespace xxxx;
bitmap: 用于唯一值比较少的column
适用范围:取值唯一性少,更新代价比较低,用or选项很高,用于data warehousing(OLAP).
create bitmap index xxx on table(column) tablespace xxxx;
index与表的存储参数不同之处:不能用pctused. index也可以对空间进行控制。
guidelines: 在独立的表空间;使用uniform extent sizes; nologging(大的index);initrans 至少要等于表上的initrans。
存储参数: alter index xxx pctfree 20 storage(next 200k pctincreat 20)
手工分配与回收空间:alter index xxx allocate extent(size 100k datafile '...'); 但这个数据文件一定是index所在的tablespace
alter index xxx deallocate;
rebuild indexes: online rebuild: 在index rebuild 可以重建,并发性高,可以移动到其他表空间,此时需要重建。
可以释放没有回收的空间。可以在normal 与reverse index之间相互转换。但b-tree与bitmap不可转换。
alter index xxx rebuild onling; 对表不locking,在运行中,保持系统并发性而用的。
coalescing indexes: alter index xxx coalesce.
检查有效性: anylyze index xxx validate structure. 更新了index统计的过程。index_status表中会改变。
drop index: 无用的index,用到很少的index(在装入大量数据时,可以先删除index,再重建);
监视index应用:alter index xxx monitoring usage; alter index xxx nomonitoring usage;
视图: dba_indexes,dba_ind_columns; dba_ind_expressions,v$object_usage;

?