Deleting duplicate indexes to improve performance and space

来源:互联网 发布:软件著作权是什么 编辑:程序博客网 时间:2024/05/16 17:55
Deleting duplicate indexes to improve performance and space.

If 2 indexes ( INDX1 INDX2 )are created for a table and the number of columns in Index INDX1 is less or equal to the number of column in index INDX2 and index INDX1 has the same columns in the same order as leading columns of index INDX2, then if index INDX1 is UNIQUE and not being used for any foreign key, then INDX1 can be dropped as it exists in INDX2.

example
CREATE TABLE EMP (
emp_id NUMBER(8) NOT NULL,
last_name VARCHAR2(20) NOT NULL,
first_name VARCHAR2(20) NOT NULL );

CREATE INDEX INDX1 ON EMP ( last_name );

CREATE INDEX INDX2 ON EMP ( last_name, first_name );

In the above exampke INDX1 can be dropped.