Currently we have a table that we use to track inivitations. We have an email field that is indexed but we also have three optional keys that the user can specify when adding new record emails. We don't allow duplicates so we have to query if the email plus the optional keys already exists. Currently the keys are only added to the select statement if they are specified. The normal case is only email is specified and using the index it works fairly quickly. When the keys are added performance drops.
Would adding three indexes affect performance for other operations? Keys are probably used infrequently that we wouldn't want to impact performance for this case.
- email, key1
- email, key1, key2
- email, key1, key2, key3
The other idea is we add 1 key.
- email, key1, key2, key3
Then always use all 3 keys in the lookup (eg. key1 = mykey AND key2 is NULL AND key3 is NULL)
See Also