Reputation: 2093
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.
Upvotes: 0
Views: 105
Reputation: 28753
This means the combination of fields must be unique.
You will get the same performance gains on SELECT
you 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.
Upvotes: 2