I’m matching some in memory lists entities with a .contains (subselect) query to filter out old from new users.
Checking for performance problems i saw this:

The oldList mostly has around 1000 users in them, while the new list varies from 100 to 500. Is there a way to optimize this query?
Absolutely – build a set instead of checking a list each time:
The containment check on a
HashSetshould be O(1) assuming few hash collisions, instead of the O(N) of checking each against the whole sequence (for each new user).