index
when to index
(1)频繁操作的、频繁用于连接的、选择性高(怎样才算高 few rows have then same value)的列。
(2)few distinct value的列适合用位图索引
(3)频繁update的不适合index
(4)bitmap-indexs do not support row-level locking???
(5)foreign key
(6)经常用到函数或表达式 则用函数索引
effect of dml oparation on indexs
insert
result in the insertion
if there is no room for the entry in the block, then it is split into
two blocks and an entry is added in the parent block to point to
the new block.
delete
analyze index idx_name validate structure;
查看index_stats
DEL_LF_ROWS NUMBER Y number of deleted leaf rows in the index
DEL_LF_ROWS_LEN NUMBER Y total length of all deleted rows in the index
类似于delete table 一样 空间没有释放出来。但和表的高水位机制不同
索引键必须保留在相对于彼此都相同的位置中,所以叶块不能进行任何移动
alter index idx_name shrink space
或
alter index idx_name coalesce
可以释放空闲的空间,如果要缩小索引则必须重构索引。
alter index idx_name rebuild[online] tablespace ts_xxx.
如果没有online 意味则重构期间表会被锁定。
update
result in a logical deletion and an insertion
监视索引的使用
(1)alter index idx_name monitoring usage.
(2)waiting......
(3)alter index idx_name nomonitoring usage.
(4)观察视图v$object_usage.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21993926/viewspace-667390/
,如需转载,请注明出处,否则将追究法律责任。