datanucleus-rdbms
datanucleus-rdbms copied to clipboard
Optimizing the fetch of map fields (1:N relations) could significantly reduce number of sql statements
The load of a Map currently can involve more than 1 SQL. This is embodied in SCOUtils.populateMapDelegateWithStoreData().
In this method we reads in the keys (if persistable), then the values (if persistable), and then the "entries" (ids of keys and values) so we can associate the keys to the values. For a Map<Persistable, Persistable> this means 3 SQL statements.
Issue 282 also had the following, which is effectively the same area. When we have a Map and want to get the entries (Map.entrySet()), we currently select the "map table". When using a join table to form the relation this will be the join table. When the key / value has its own table we simply have a FK to the key table or value table respectively. We don't join across right now (although there is some code in there that doesn't work for all situations).