• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

n+1 solution, is it good , really ?

 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I have been reading Hibernate In Action book and a question comes to my mind .
This book suggests a solution to n+1 problem :
Make your default fetching strategy is lazy (at mapping level) then override it with eager fetching in code.
Well, it seems to me that this approach imposes extra load on the database and the application in overall.
Any clarfications ?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, it is a good solution because when you have more than one colletion in a mapped object, you can only eager load one Collection. Each Use Case could need a different Collection eager loaded for performance. So it is better to set it to eager at time of creating the query. Also look at "subselect" for laxy loading, but when you access the Collection, it will run a single query to load the Collection, using the original first query as a subselect in that next query.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic