You are right on putting on the primary key. Its the quicker way to do things.
This is kinda evil. If you cause it to count all results, it doesnt\\' return back with the results right away. So that if you have 3 million rows, it has to go through all 3 million, even if its indexed, count the matching rows and return.
Instead, do a \\"SELECT 1 FROM BLAH WHERE EXISTS ... \\" it find the first match, and just returns.
-s
If you don\\'t want to go that (recommended) route, you could get the new username and then do a select count(*) statement where the username is equal to the new one. If the result is greater than 0, you have a duplicate.