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 ind
By declaring an index on (phrase, assoc, floatval)
you will get a "covering index", which allows the query posted in the question to performed without even accessing the table. Assuming that either phrase
or assoc
alone is highly selective (not many rows share the same value for the field), creating an index on that field alone should yield almost the same performance.
Generally, you will want to limit the number of indexes to the smallest set that gets your frequent queries up to the desired performance. For each index you add to a table, you pay some disk space, but more importantly you pay the price of having the DBMS do more work on each INSERT
into the table.