-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: n+1 select problem
PostPosted: Thu Sep 07, 2006 1:51 am 
Newbie

Joined: Thu Jul 27, 2006 10:35 am
Posts: 16
Hi All

I have been reading quiet a lot about Hibernate. One thing which I could not get very clearly was regarding the n+1 select problem.

I read about Hibernate solves a perennial problem (which is n+1 select problem).
I would like to know what is this n+1 select problem. Can some ellaborate on this. Would be good if some could give an illustration


Regards


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 07, 2006 10:24 am 
Senior
Senior

Joined: Wed Aug 17, 2005 12:56 pm
Posts: 136
Location: Erie, PA (USA)
The problem relates to retrieving data from tables that have a one to many relationship. Basically, the "n + 1" relates to the number of sql queries that need to be run to fully hydrate all the objects.

For instance, you have two tables: orders & orderlines. For some order, you have 10 order lines. Since Hibernate tries to load the least amount of data possible, with certain fetching strategies, you could end up issuing 11 queries to the database.

I'm not going to go into dealing with this -- there is a lot of information on that topic. But I will say that this behavior is not always bad -- it depends on your use case.

Curtis ...

_________________
---- Don't forget to rate! ----


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.