I know that the not in query is VERY slow. The suggestion I have seen
here is to do a not exists with a sub select. There is a faster, easier
way. Do a left join and look for a null in the field on the table where
you want no match.
select a,b frrom c where b not in (select b from d);
select a,b from c where not exists (select b from d where c.b=d.b);
select a,b from c left join d on c.d=d.b where d.b is null;
This last one is faster, and more portable.