-
If I declare a unique index on multiple fields, does that mean the combination has to be unique or that each field must be seperately unique.
-
Is there a performance gain from specifying a unique constraint? I assume that this would allow the engine to stop searching and return the result if it is guaranteed to be unique.
If I declare a unique index on multiple fields, does that mean the combination
Share
This means the combination of fields must be unique.
You will get the same performance gains on
SELECTyou would get from a regular composite index if you are using a prefix of the key. However, unique indices have an additional performance penalty on insert, since it must be checked that the value is unique.