Skip to content

Join scanning #38

Closed Answered by stephenafamo
hiendaovinh asked this question in Q&A
Mar 30, 2023 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Preloading a ToMany is kind of difficult. By default, using a left join that has more than one match will duplicate the row for each match. There are several ways to make this work.

Option 1: Caching

Have a cache of all scanned objects by primary key and reuse them if encountered again. I think this is very error-prone. It also requires the scanner to keep track of every row which breaks features like Cursor. Also, significant changes will have to be made to the scan package and I think this may be fighting against SQL which is not what Bob is about.

Additionally, the complexity of this method grows with each nested load. It would seem that a flattened cache of each object and their relat…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@hiendaovinh
Comment options

Answer selected by hiendaovinh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants