I have found a strange behavior when merging entities with "mapped by" set on @OneToMany relation. Even if object is fetched with find on the same transaction, merge is very slow. It's because on merge every single relation marked as LAZY is fetch from database.
Attached two examples - one with mapped by, second with adding entities list without "mapped by". The difference is huge event for such small objects - 2ms (without mapped by) vs ~50ms (with mapped by)
Is there any chance to optimize this case? Removing mapped by in our case can be quite hard, and now we have few cases where 'child' part of relation have almost 10k objects, so merging parent is also memory inefficient.