[odb-users] Parent/child datamodel and performance
Special Gunpowder
specialgunpowder at outlook.com
Mon Mar 8 12:14:55 EST 2021
Thanks a lot for the feedback and advice Boris.
Yes, I do need all the data loaded eagerly.
No, there is no sharing of child/grandchild records.
I was not aware of the ability to load all related objects with a single query using object loading views - I will read the manual chapter on views and see if that might work. If there is an example that illustrates that approach, please let me know.
If that is not an option, I will remodel and make all the children db value types. I think I only modelled the parent/children as related entities because with db value types I cannot have containers of containers so no grandchildren... but I think I can work around that.
Thanks again!
________________________________
From: Boris Kolpackov <boris at codesynthesis.com>
Sent: Monday, March 8, 2021 10:58 AM
To: Special Gunpowder <specialgunpowder at outlook.com>
Cc: odb-users at codesynthesis.com <odb-users at codesynthesis.com>
Subject: Re: [odb-users] Parent/child datamodel and performance
Special Gunpowder <specialgunpowder at outlook.com> writes:
> How can this be improved?
Do you actually need to load all of the RelChild and/or RelGrandchild
eagerly?
> Do I need to remodel implement all the children as db value types?
That would definitely help.
Otherwise, if you don't need all the RelChild/RelGrandchild loaded,
then you can consider lazy loading (see lazy_ptr in documentation).
Even if you do need to load them all eagerly, you can most likely
optimize things by switching to lazy_ptr and then loading all the
related objects with a single query using object loading views.
Finally, if RelChild/RelGrandchild can be shared by multiple objects,
make sure that you use session to avoid loading the same objects
repeatedly.
More information about the odb-users
mailing list