Subject | Re: [firebird-support] Doubt creating index |
---|---|
Author | Helen Borrie |
Post date | 2013-02-14T00:28:08Z |
At 12:44 p.m. 14/02/2013, Ruben Marti wrote:
./hb
Helen Borrie, Support Consultant, IBPhoenix (Pacific)
Author of "The Firebird Book" and "The Firebird Book Second Edition"
http://www.ibphoenix.com/products/books/firebird_book
__________________________________________________________________
>I have a table with several hundreds of thousands of records that has aNo use at all.
>composite primary key, with the fields "START_DATE" and "ITEM".
>
>I honestly do not know if it's interesting declare the index as "UNIQUE"
>when it can not have duplicate records.
>For optimization reasons, I need an index composed of the fields "ITEM" andYou should get optimal performance by creating a simple index on START_DATE. The optimizer will use the PK index if it has to search on ITEM alone.
>"START_DATE".
>What will I gain or loss if the index is declared "UNIQUE"?No gain. Possible confusion for the optimizer. It already knows that combination is unique.
>What type (UNIQUE or NOT UNIQUE) is faster to retrieve the data?Irrelevant.
>What type (UNIQUE or NOT UNIQUE) is faster to insert the data?Irrelevant.
>What type (UNIQUE or NOT UNIQUE) is faster to update the data?If START_DATE is an updatable field, then you have a design flaw that is likely to hurt performance and also make your data vulnerable to invisible corruption by users, regardless of whether the index is unique or not.
./hb
Helen Borrie, Support Consultant, IBPhoenix (Pacific)
Author of "The Firebird Book" and "The Firebird Book Second Edition"
http://www.ibphoenix.com/products/books/firebird_book
__________________________________________________________________