ORACLE_基础十(index)
2015-04-04 21:46
239 查看
Classification of Indexes
1.Logical:a.Single columne or concatenated
b.Unique or nonunique
c.Function-based
d.Domain
2.Physical:
a. Partitioned or nonpartitioned
b.B-tree:Normal or reverse key
c. Bitmap
B-Tree VS Bitmap
B-tree BitmapSuitable for high-cardinality columns Suitable for low-cardinality columns
Updates on keys relatively inexpensive Updates to key columns very expensive
Inefficient for queries using OR predicates Efficient for queries using OR predicats
Useful for OLTP Useful for data warehousing
Creating B-Tree Indexes
CREATE INDEX hr.employees_last_name_idx ON hr.employees(last_name) PCTFREE 30 STORAGE(INITAIL 200K NEXT 200K PCTINCREASE 0 MAXEXTENTS 50 ) TABLESPACE index
Creating Indexes:Guidelines
1.Balance query and DML needs2.Place in separate tablespace.
3.Use uniform extent sizes: Multiples of five blocks or MINIMUM ExTENT size for tablespace
4.Consider NOLOGGING for large indexs
5.INITRANS should generally be higher on indexes than on the corresponding tables.
Storage Params for Indexes
ALTER INDEX emplyees_last_name_idx STORAGE(NEXT 400K MAXExTENTS 100);
Alloc & Dealloc Index Space
ALTER INDEX orders_region_id_idx ALLOCATE EXTENT(SIZE 200K DATAFILE '/DISK6/index01.dbf'); ALTER INDEX order_id_idx DEALLOCATE UNUSED
Rebuilding Indexes
Use the ALTER INDEX command to :1.Move an idnex to a different tablespace
2.Improve space utilization by removing deleted entries
ALTER INDEX orders_region_id_idx REBUILD TABLESPACE index02;
Offline Index Rebuild
1.Lock the table2.Create a new , temporary index by reading against the contents of the existing index
3.Drops the original index
4.Renames the temporary index tomake it seem to be the original index
5.Remove the table lock
Rebuilding Indexes Online
Indexes can be rebuilt with minimal table lockingALTER INEX order_id_idx REBUILD ONLINE
1.Lock the table
2.Create a new , temporary and empty index and an IOT to store on-going DML
3.Release the table lock
4.Populate the temporary index by reding against the contentts of the existing index.
5.Merge contents of the IOT in with the new index
6.Lock the table
7.Final merge from IOT and drop the original index
8.Renames the temporary index tomake it seem to be the original index
9.Remove the table lock.
Coalescing indexes
Checking Index Validity
ANALYZE INDEX orders_region_id_idx VALIDATE STRUCTURESELECT height,name,lf_rows,lf_blks,del_lf_rows FROM index_stats;
Dropping Indexes
1.Drop and re-create an index before bulk loads2.Drop indexes that are infrequently needed, and build indexes when nexessary
3.Drop and re-create invalid indexes
DROP INDEX hr.departments_name_idx
Identifying Unused Indexes
1.To start monitoring the usage of an index:ALTER INDEX ht.dept_id_idx MONITORING USAGE
2. To stop monitoring the useage of an index
ALTER INDEX hr.dept_id_idx NOMONITORING USAGE
结果在:
select * from v$object_usage;
Getting Index Information
DBA_INDEXES: provides information on the indexesDBA_IND_COLUMNS: provides information on the columns indexed
V$OBJECT_USAGE: Provides information on the usage of an inde
相关文章推荐
- Oracle之索引(Index)实例解说 - 基础
- Oracle基础学习笔记(二)(Index)
- Oracle之索引(Index)实例讲解 - 基础
- Oracle PL/SQL语言基础
- Oracle PL/SQL语言基础
- [转贴]Oracle PL/SQL语言基础
- Oracle 基础和管理
- 为数据库的表自动生成行号----为分页打好基础(仿Oracle的ROWNUM)
- Oracle PL/SQL语言基础
- Oracle PL/SQL语言基础
- ORACLE基础知识
- 关于Oracle 9i 跳跃式索引扫描(Index Skip Scan)的小测试
- oracle基础学习
- oracle程序开发基础一
- Oracle PL/SQL语言基础
- 基于oracle的面向对象技术基础简析
- [转贴]Oracle PL/SQL语言基础
- 为数据库的表自动生成行号----为分页打好基础(仿Oracle的ROWNUM)
- oracle架构的基础知识
- Oracle 的 Index