• 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

Perfomance Issue: Persisting a large collection.

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Im using Hibernate3.2.3.ga + spring 2.0.

I have an Object Grid, which contains a collection of Points. Point has just latitude(float) and longitude(float) attrbs.
The problem is that the grid object actually contains a lot of Points, say more than 13000 points. When I tried performing a normal save using the Springs HibernateTemplate.save(Object o) it tooked more than 15 minutes to perform the save operation.

Which optimization technique should I use in order to perform this saving in less time?


Thanks.

Esteban.
 
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
The big thing is that all those objects being stored into the Session and not being Batched.

There are a few options.

1) In a for loop set the batch size to say 50. When you reach 50 do a session.flush and session.evictAll() to remove objects in the Session. This will help a little bit. Test out batch sizes to see where you get the best performance.

2) How are those points created, you could do more batch SQL code instead of creating objects and using session.saveOrUpdate()

3) If this is truly a batch update of tons of records, maybe Hibernate isn't the best choice for this. You can always go low level and getConnection() from the session and do it via JDBC.

Mark
 
esteban gomez
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
thanks for the reply.

Actually I used option 1) and performance improved a lot. The code I used was the following:
 
Mark Spritzler
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
Nice.

One question, I thought the benefit of using the HibernateTemplate in Spring was so that you didn't have to do beginTransaction(), commit() and rollback() yourself.

Ah, and you are one of those "final" type guys. ;)

Mark
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic