Very slow WHERE IN query on very large table - postgresql 9.6
To Speed up the query,

We may use join instead of subquery

Try this query:

SELECT a1.event_id 
FROM attendees a1
JOIN attendees a2
    ON a1.attendee_id = a2.attendee_id
        and a2.event_id = $eventId 


To make is faster check that if you can create CLUSTER on that table with index on Primary key

Note: cluster a table according to an index reference