Hi,
First do you update statistics with vaccum ????
Second, execute your query with explain in order to see
if postgresql use index .
For your function do you use the keyword WITH ( ISCACHABLE)
in order to use index for you funtcion ????
Cheers,
PEJAC pascal