Re: Does it make sense to have 2 unique keys in one table?
Posted in 1995
Topics: Performance & Tuning
dmajor7@aol.com (Dmajor7) wrote: > (previously quoted material deleted) >It seems to me that the point isn't whether both indexes are necessary. I >think they must be, otherwise why would the question have been asked. It >seems to me the question is whether both indexes need to be declared to be >unique. Since key 2 is unique and since key1 is a superset of key2 then >key1 must be unique. Although I am no expert in this area, it seems to me >that you could gain some performance by not requiring key1 to be unique. >Key2 being unique is going to insure that key1 is unique anyway so why >waste time having the database check for something that is impossible. > >Ken Denny >Insight Industries, Inc. > >All opinions expressed are my own. The question about performance of a unique index versus a non-unique index is going to be dependent on the particular algorithm used to check for uniqueness. Also, whether or not an index is unique may (or may not) influence a later choice made by a query optimizer. It might be possible to answer this sort of performance question for a particular implementation and a particular application, but there is unlikely to be a general answer. Keith Hare JCC Consulting, Inc. (http://www.jcc.com)