[odb-users] Parent/child datamodel and performance

Boris Kolpackov boris at codesynthesis.com
Mon Mar 8 05:58:27 EST 2021

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

> 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

More information about the odb-users mailing list