Migration from Kodo: Any way to make it store foreign keys to later get already loaded objects from cache (for performance)?


Hi Andy

There is no fetch plan involved. On loading the persons the sql gets the foreign key to the enterprise according to the logs. So it will not load the enterprise (and I don't want it to).

Just to be clear: this is not about loading the enterprise on loading the person.

This is about using the the foreign key (PerEntID) that was retrieved with the person on later call to getEnterprise() to see if the enterprise is now in the cache. Instead of always going to the DB.



Only you know what is in the fetch plan for a retrieve, and what sql is invoked to retrieve what it retrieves. To check a cache it needs the id of a related object, and ut has to get that from somewhere.

Impossible to say more without basic info



I try to migrate a legacy application (on Kodo 3.4, develped over 10+ years).
I now created all needed plugins so our very much not JDO compliant code runs.
However, now that it works I have a massive performance problem. The problem is that datanucleus does not seem to use the foreign keys to check if the related object is already in the cache. That means if using datanucleus an order of magnitude more queries to the DB happen.

We have Enterprise and Person. Person has a foreign key to Enterprise.If I load 2 Person from the same enterprise, p1 and p2 and then call p1.getEnterprise() it will load the enterprise from the DB.
If I then call p2.getEnterprise() it will again load the same Enterprise from the DB.
Kodo 3.4 will store the foreign key for related objects and then use that to lookup the object in the cache.

  • Is there a way to make datanucleus store the foreign key and later use that to get the related object from cache?
  • Can anybody say how much work it would be to make datanucleus do that?

Because with this problem I probably have to cancel the migration :(

Thanks and kind regards