title: SQL indexing on varchar
body: <p>I have a table whose columns are <code>varchar(50)</code> and a <code>float</code>. I need to (very quickly) look get the float associated with a given string. Even with indexing, this is rather slow.</p>
  
  <p>I know, however, that each string is associated with an integer, which I know at the time of lookup, so that each string maps to a unique integer, but each integer does not map to a unique string.  One might think of it as a tree structure.</p>
  
  <p>Is there anything to be gained by adding this integer to the table, indexing on it, and using a query like:</p>
  
  <pre><code>SELECT floatval FROM mytable WHERE phrase=givenstring AND assoc=givenint
  </code></pre>
  
  <p>This is Postgres, and if you could not tell, I have very little experience with databases.</p>