|
Ok, I don't mind if it's a bug or improvement, but I do think that changing this might improve performance in quite a few cases. Why does PersistentBag.initializeFromCache need to eagerly fetch all entries? Perhaps it could load them lazily. This would result in entity proxies for all cache-misses, allowing @BatchSize to spring into action when using one of them. One step further would be to eagerly create proxies for all entities as soon as the FK values are loaded from the cache. This would allow other collections to join in the batchloading as well.
The main problem with the current approach is that all three parties (Company, Company.users and User in the testcase) live in different caches, possibly with different characteristics. It is likely that for every Company, a corresponding Company.users entry exists, but User has very different counts, which could go into the thousands. If Company and User have different lifespans and very different counts, it is very likely that cache misses will occur, potentially causing very high numbers of 'fetch-one' queries.
|