When we use in and not in, it will take a long time to get the results. because it scans all the records of the table. we can use left join instead of in or not in like the following:
1. select * from table1 where tabel1.name not in (select name from table2) is equals to
select a.* from table1 a left join table2 b on a.name = b.name where b.name is null.
2. select * from table1 where tabel1.name in (select name from table2) is equals to
select a.* from table1 a left join table2 b on a.name = b.name where b.name is not null.