Unique indexed column in where clause and mysql execution after finding first row
If the constraint on login is unique... any serious sql database vendor will stop searching at the first and only possible occurence met. 

In the second case, it will stop at the first and only possible occurence, and returns the record if the password is '123', nothing if not.