title: How to properly index my database to increase query performance
body: <p>I'm working on simple log in page using OpenID: if the user has just registered for an OpenID, then I need to create a new entry in the database for the user, otherwise I just display their alias with a greeting. Every time somebody gets authenticated with their Open ID, I must find their alias by looking up which user has the given OpenID and it seems that it might be fairly slow if the primary key is the UserID (and there are millions of users).</p>
  
  <p>I'm using SQL Server 2008 and I have two tables in my database (Users and OpenIDs): I plan the check if the Open ID exists in the OpenIDs table, then use the corresponding UserID to get the rest of the user information from the Users table.</p>
  
  <p>The Users table is indexed by UserID and has the following columns:</p>
  
  <ul>
  <li>UserID (pk)</li>
  <li>EMail</li>
  <li>Alias</li>
  <li>OpenID (fk)</li>
  </ul>
  
  <p>The OpenIDs table is indexed by OpenID and has the following columns:</p>
  
  <ul>
  <li>OpenID (pk)</li>
  <li>UserID (fk)</li>
  </ul>
  
  <p>Alternately, I can index the Users table by UserID and OpenID (i.e have 2 indexes) and completely drop the OpenIDs table. </p>
  
  <p>What would be the recommended way to improve the query for a user with the matching OpenID in this case: index the Users table with two keys or use the OpenIDs table to find the matching UserID?</p>