Dror,
> I am using 7.4, and had tried NOT EXISTS and didn't see any
> improvements.
It wouldn't if you're using 7.4, which has improved IN performance immensely.
What happens if you stop using a function and instead use a subselect?
--
-Josh Berkus
Aglio Database Solutions
San Francisco