If I understand correctly, it is what I did in my previous attempt.
https://github.com/ezsystems/ezpublish-legacy/blob/ezp-22923-delete_attribute_links/kernel/classes/datatypes/ezobjectrelationlist/ezobjectrelationlisttype.php#L833

As @glye pointed out, `removeThis` is called in other use cases leading to side effects.

I agree with you that performance wise we could limit the call to the query to a given list of attributes. But this code is not often called so it's not a big deal.