How can performance of queries containing keywords like IN, EXISTS, etc. be optimized?
Try to use equivalent query with JOIN and without IN or EXISTS and compare the runtimes:

select id
from table1 join table2 on table1.A = table2.B
where table2.C &lt; 200
group by id


Look also at similar question here, where similar optimization is proposed for much more complex query: https://stackoverflow.com/q/17038193/684229. But note that the JOIN solution is not always faster; sometimes, surprisingly, the IN/EXISTS queries come out as faster. Depends on the optimizer. That's why I suggest to test both variants.