请问这里定义一个A+B+C的复合索引是否对DELETE删除有帮助呢?谢谢!
5 个解决方案
#1
我的理解是复合索引对表的查询会有帮助,但个人意见索引这个东西还是不要乱用,弄不好可能会对表的后续操作产生影响,比方说对表的更新。你可以参考一下
http://www.cnblogs.com/wenly/articles/1240321.html这篇文章,或许对你有点帮助。
#2
DELETE FROM TBL
WHERE A = 'A10'
AND B = 'B10'
AND C = 'C10'
DELETE STATEMENT, GOAL = ALL_ROWS 1 1 21
DELETE JXKH_REFORM TBL
INDEX RANGE SCAN JXKH_REFORM IND_ABC 1 1 21
#3
DELETE FROM TBL WHERE A=:a and B=:b and C=:c;
create table tbl(A VARCHAR2(10),B VARCHAR2(10),C VARCHAR2(10));
BEGIN
FOR I IN 1..10000 LOOP
INSERT INTO tbl VALUES ('A'||I,'B'||I,'C'||I);
COMMIT;
END LOOP;
END;
CREATE INDEX IND_ABC ON TBL(A,B,C);
DELETE FROM TBL
WHERE A = 'A10'
AND B = 'B10'
AND C = 'C10';
DELETE STATEMENT, GOAL = ALL_ROWS 1 1 21
DELETE JXKH_REFORM TBL
INDEX RANGE SCAN JXKH_REFORM IND_ABC 1 1 21
#4
是可以走到索引的·~
#5
有
#1
我的理解是复合索引对表的查询会有帮助,但个人意见索引这个东西还是不要乱用,弄不好可能会对表的后续操作产生影响,比方说对表的更新。你可以参考一下
http://www.cnblogs.com/wenly/articles/1240321.html这篇文章,或许对你有点帮助。
#2
DELETE FROM TBL
WHERE A = 'A10'
AND B = 'B10'
AND C = 'C10'
DELETE STATEMENT, GOAL = ALL_ROWS 1 1 21
DELETE JXKH_REFORM TBL
INDEX RANGE SCAN JXKH_REFORM IND_ABC 1 1 21
#3
DELETE FROM TBL WHERE A=:a and B=:b and C=:c;
create table tbl(A VARCHAR2(10),B VARCHAR2(10),C VARCHAR2(10));
BEGIN
FOR I IN 1..10000 LOOP
INSERT INTO tbl VALUES ('A'||I,'B'||I,'C'||I);
COMMIT;
END LOOP;
END;
CREATE INDEX IND_ABC ON TBL(A,B,C);
DELETE FROM TBL
WHERE A = 'A10'
AND B = 'B10'
AND C = 'C10';
DELETE STATEMENT, GOAL = ALL_ROWS 1 1 21
DELETE JXKH_REFORM TBL
INDEX RANGE SCAN JXKH_REFORM IND_ABC 1 1 21
#4
是可以走到索引的·~
#5
有