set work_mem=24000; before running the query.
postgres is doing merge and sort on disc, that's always slow.
is there an index on column isin ?