Hi Nima,
I'm not sure whether ~0.8 secs for ~800 rows is considered still being a problem but I suppose it
can be if the number of members are, say, ten times that of your example.
Anyway, it might be interesting to try and replace the last WHERE clause (the one with the subselect)
with a construct using EXCEPT (Postgres vocabulary) and MINUS (Oracle vocabulary) respectively.
Unless I'm overlooking something here I do believe that an EXCEPT (or MINUS) could be useful here:
EXCEPT acts in the opposite way of a UNION in that it subtracts the rows returned by the second query part
from those returned by the first query part instead of adding them like UNION does. I think it would be analogous to
the current "not in (*subselect*)", which is also aimed to reduce the number of rows, but probably "EXCEPT" does it faster.
Just a thought.