SQL (Postgres): Subquery in WHERE clause with IN operator is slow
Test
select count(*)
from person p
cross join task t
where EXISTS (
    select NULL
    from task_participant tp
    where tp.person_id = p.id
      AND t.id = tp.task_id )
  and p.id = 1234