ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brice Ruth <bdr...@gmail.com>
Subject Re: What is N+1
Date Wed, 09 Feb 2005 16:22:37 GMT
Vic, probably isn't an issue for you since you only use HashMaps ;)


On Wed, 09 Feb 2005 08:12:32 -0600, Vic Cekvenich <vin@friendvu.com> wrote:
> Which I could do with a join on SQL side. I can't see how this is
> something I'd use or how it' scale, but.... I guess somone uses it.
> THANKS for the education.
> .V
> 
> Kris Jenkins wrote:
> 
> >
> >
> > The N+1 selects problem is when you query for n parents, and you need
> > one extra query for the children.  Internally, this happens:
> >
> >    List parents = sqlMap.queryForList( "getParents", parameter );
> >    for ( Iterator i = parents.iterator(); i.hasNext(); ) {
> >       Parent p = (Parent) i.next();
> >       List children = sqlMap.queryForList( "getChild", p.getId() );
> >       p.setChildren( children );
> >    }
> >
> > So you end up with 1 query for the parent list, plus one extra for
> > each parent to get the children = n + 1.  Rather inefficient.
> > This is the problem that 2.0.9 fixes.
> >
> > Sorry for the confusion.
> > Kris
> >
> 
> --
> Forums, Boards, Blogs and News in RiA <http://www.boardVU.com>
>

Mime
View raw message