I have a table with columns user_id, email, default. Default stores 'Y' or 'N' depending if the email is the users default email. Each user can have only one default email.
When a user is doing an update or insert on the table, in my SP I check if the user has passed isDefault as 'Y'. If so, I need to update all the entries for that user to make default 'N'. My question is: considering there are no locking issues (not more than one thread will request data from the table for a particular user) which one amongst the following queries is least time consuming:
update table
set default = 'N'
where user_id = 'abc'
and default = 'Y'
(Overhead of where default = 'Y' check)
OR
update table
set default = 'N'
where user_id = 'abc'
(Overhead of updating all records for the user)