• 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

Performance Issue in Hibernate?

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi i am facing very strange behavior in hibernate which is described below

I have written a function which fetch one city of a particular state the hbm mapping of files are given below:

city.hbm

State.hbm

From my action class I am calling the method

IMPL class Method:



The whole application invokes when I upload some users into database, before uploading users I also checked the city related to that user for that I invoke above method. The method works fine with few records but it takes lot of time when we upload say 5000 users.
I also put debug statements and found that to execute the
city = (City) criteria.uniqueResult();
it takes 4ms for first record then it keeps on increasing and reached to 190 ms for 3500 users.

I had also tried to put second level caching, as a result the SQL query is not executing every time but it still takes same time .

But if I comment the line city = (City) criteria.uniqueResult(); then a unique behavior can be seen like it differs from 5ms to 15 ms .
If you carefully noticed the code I have not done any complex join or something and it also works fine for few records but why the time keeps on increasing continuously for only this method is very strange for me.

Please provide some solution. Thanks
 
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
Well, you can consider the Heap space. So for every object you load, it takes up heap space. If you load more and more, garbage collection comes into play as well as the sizing of the heap space.

You can try to increase it with -Xmx and -Xms to see if that helps.

Also do you need to load all those users, or can you do some batch, and pagination logic to not load 5000 objects at once into the Session.

Let us know how that goes.

Mark
 
akash yadav
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark Spritzler wrote:Well, you can consider the Heap space. So for every object you load, it takes up heap space. If you load more and more, garbage collection comes into play as well as the sizing of the heap space.

You can try to increase it with -Xmx and -Xms to see if that helps.

Also do you need to load all those users, or can you do some batch, and pagination logic to not load 5000 objects at once into the Session.

Let us know how that goes.

Mark



Thanks for your response Mark. I got your point but I want to know there are are several methods in application which are showing consistent behavior only this method more precisely only that particular line of code is creating problem whereas I have now save the multiple database hits also by implementing second level cache. Also I didn't understood about paginataion logic I am using aop:config in my application where the transaction commits after the execution of all methods.
 
Enjoy the full beauty of the english language. Embedded in this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic