Subject | Re: [firebird-support] What is duplicate index? |
---|---|
Author | Svein Erling Tysvaer |
Post date | 2006-08-23T07:10:44Z |
Mohammad Jeffry wrote:
CREATE INDEX DuplicateIndex1 ON TEST(FIELDA);
CREATE INDEX DuplicateIndex2 ON TEST(FIELDA, FIELDB);
CREATE INDEX OKIndex ON TEST(FIELDB, FIELDA);
CREATE INDEX DuplicateIndex3 ON TEST(FIELDB);
CREATE INDEX OKIndex2 ON TEST(FIELDA DESC);
Since the primary key automatically produces an index, DuplicateIndex1
is a copy of the primary key, DuplicateIndex2 may be different (I do not
know), but since FIELDA is unique (the primary key must be unique),
there is no case where it is of any use. OKIndex creates an index first
on FIELDB and then on FIELDA, so DuplicateIndex3 doesn't add anything
not already available through OKIndex.
I added OKIndex2 since Firebird uses unidirectional indexes and there is
a difference between the default ASC index and a DESC index.
HTH,
Set
> I understand that duplicate index can slow down firebird. What is duplicateCREATE TABLE TEST(FIELDA INTEGER NOT NULL PRIMARY KEY, FIELDB INTEGER);
> index? How can one create duplicate index? example please
CREATE INDEX DuplicateIndex1 ON TEST(FIELDA);
CREATE INDEX DuplicateIndex2 ON TEST(FIELDA, FIELDB);
CREATE INDEX OKIndex ON TEST(FIELDB, FIELDA);
CREATE INDEX DuplicateIndex3 ON TEST(FIELDB);
CREATE INDEX OKIndex2 ON TEST(FIELDA DESC);
Since the primary key automatically produces an index, DuplicateIndex1
is a copy of the primary key, DuplicateIndex2 may be different (I do not
know), but since FIELDA is unique (the primary key must be unique),
there is no case where it is of any use. OKIndex creates an index first
on FIELDB and then on FIELDA, so DuplicateIndex3 doesn't add anything
not already available through OKIndex.
I added OKIndex2 since Firebird uses unidirectional indexes and there is
a difference between the default ASC index and a DESC index.
HTH,
Set