So if the lookup is 10 bytes and you are fetching 10 records of the child, your payload size is 100 bytes
instead of 10 bytes. ( I wonder if JDBC makes some internal optimisations - keeps a pointer or something
to same record if duplicates exist?)
That's not a problem per se, but which one is better:
1. This approach or ... 2. Using an "in clause" and making another round-trip?
Cheers
Abdullah
Michal Malecki wrote:
Well, I think you need only simple join in your sql, no extra features of ibatis needed: select * from CHILD, PARENT where parent_id=PARENT.id; am I right? Michal Malecki
What about relationships from the child up to the parent? Are they also classified as N+1?
Suppose we have child table with a fk of parent_id.
if I do:
SELECT * from CHILD
I'll get a column with parent_id with values.
Now suppose I also want details pertaining to the parent_id along with the recordset of Child, I need not do 10 separate selects for the parent ... is this also an N+1 problem?
What is the preferred iBatis model for this?
Cheers
Abdullah
Kris Jenkins wrote:
friendVU admin wrote:
What is n+1?
.V
n++! :-P
It's when each child object in a complex query has to be selected seperately. If 'parent' has 10 'children', you end up with 10+1 select statements being issued. See the developer's guide under 'Avoiding N+1 selects' for the full lowdown. Version 2.0.9 comes with new groupBy goodness to banish the N+1 problem.
Kris