Use implicit join for where clause on Many2One
The subquery in the form of
column IN (SELECT id FROM ...) can be very slow because they are often SubPlan. This means that they are evaluated for each row. So this has a complexity of O(n^2).
But as we do that only on
id which is the primary key we could limit the subquery to fetch only one id per row using a clause like:
column IN (SELECT id FROM ... WHERE ... AND id = column). The complexity thanks to the index becomes O(n log(n)).