title: When users login to a site - should I select by the username and password, or just by the username?
body: <p>I'm using PHP and mySQL in a site I design from scratch.</p>
  
  <p>When a user logs in to the site, should I :  </p>
  
  <ul>
  <li>make the query <code>WHERE username='username' AND password='password'</code>, in which case I need to index the username and password fields, and can return a "Bad login" if one of the details is incorrect</li>
  </ul>
  
  <p>or</p>
  
  <ul>
  <li>Make the query <code>WHERE username='username'</code> only, in which case I need to index just the username field, but need to check that the passwords match in the server side code</li>
  </ul>
  
  <p>?</p>
  
  <hr>
  
  <p><strong>UPDATE:</strong><br>
  This question is about good practice. It is about whether the pros of adding an index on the password field so I can get a response from the DB only if both of the details are correct, outweighs the cons of the space and size this index will take.<br>
  I don't think the specific of my system (other than the programming language, and DB type) are relevant, and will help.</p>