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
It couldn't hurt to try adding the int and making your index on int, varchar and include float - this would be covering and pretty efficient - not sure if Postgres has included columns - if it doesn't simply add it to the index itself.
There are several other techniques you could look into (I'm not familiar with all Postgres features, so I'll give them by SQL Server name):
Indexed views - you can effectively materialize a view which joins several tables - so you could join your varchar to your int and have your index on int and varchar and float
Included columns - you can include columns in an index to ensure that the index is covering - i.e. have an index on varchar include (float) - if your index isn't covering, the query optimizer is still going to have to use the index and then do a bookmark lookup to get the remaining data.