> select key from inv_word_i where word='whatever' order by count desc ;
>
> and this is fast, however, if I use:
>
> select key from inv_word_i where word~'^whatever.*' order by count desc ;
>
> it is very slow.
Did you try '^whatever' instead of '^whatever.*'? Based on common
sense, the former should be much faster than the latter, which would
match any cahracter any number of times, unless the regexp is
optimized to avoid that.
--Gene