Hello,
Here I have a small doubt about validating UserName and Password.
I validate username and password with following quey (forget about case-sensitiveness of password) :
select password from table where username='Uname' and password='pwd';
Now in second scenario, I use following :
select password from table where username='Uname'
and validate password in .NET code.
1) If user having 'Uname' does not exists in database then which query is faster (first or second)?
2.1) If user exists and password is not matching then which is faster?
2.2) 2.1 + If there is clustered index on username column, is first query optimized?
Thanks
As long as you have index defined for username column, both queries should be nearly identical, if not the same, in terms of performance. The portion for validating the password using .NET code should be almost instantaneous, so you won't need to worry about that either. Unless you're doing this thousands (or tens of thousands) time per second, I wouldn't worry about it.
No comments:
Post a Comment