SQL indexing on varchar

Posted by alex on Stack Overflow See other posts from Stack Overflow or by alex
Published on 2010-04-13T18:56:20Z Indexed on 2010/04/13 19:03 UTC
Read the original article Hit count: 291

Filed under:
|
|

I have a table whose columns are varchar(50) and a float - I need to (very quickly) look get the float associated with a given string. Even with indexing, this is rather slow. 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. Is there anything to be gained by adding this integer to the table, indexing on it, and using a query like SELECT floatval FROM mytable WHERE phrase=givenstring AND assoc=givenint? This is Postgres, and if you couldn't tell, I have very little experience with databases.

© Stack Overflow or respective owner

Related posts about sql

Related posts about Performance