use join instead of where in();
pgsql-performance by date:
Соглашаюсь с условиями обработки персональных данных