• Post Reply Bookmark Topic Watch Topic
  • New Topic

do you see any possible causes for Performance issue

 
Sanil Joseph
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



The sql query used in this was executed below 1 second
 
fred rosenberger
lowercase baba
Bartender
Posts: 12341
38
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure what you're expecting here. I doubt many people will take the time to go through a 500+ line method in an attempt to find something that may not even be there. Do you have a reason to think there is a performance problem? If so, why?

Have you run this through a profiler and identified any bottlenecks?

One of the biggest wastes of time is to try and optimize code that doesn't need it - or to optimize code without knowing where (or even if) there is a problem.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35709
408
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Samil,
Welcome to JavaRanch!

I see a few problems:
  • maintenance - a 500 line method is impossible to understand later on and will cause whomever has to maintain this code a big headache
  • you don't show what the SQL statement is which is the most likely to be a performance issue in such code
  •  
    Sanil Joseph
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    thanks Jeanne for your reply.
    I didnt place the query because I have confirmed that it was not the query which was takin time. The SQL query got executed below 500 ms.
    The piece of code was taking around 4000ms for execution.
    I doubt whether the finally clause is the culprit. The reponse time I mentioned above is average time received on running this in JMeter.
     
    Sanil Joseph
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Also I would like to know, if we are calling separate methods where we create some objects and return those objects, would cause problem. These method calls happens inside a loop i.e. these object creations are happening inside a loop. So would there be a considerable increase in time if call separate method rather than creating it in the original block itself.
     
    Andrei Matyas
    Greenhorn
    Posts: 25
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    You do a lot of things here ....
    Just an idea : Try to use a connection pool or use the same connection instead of opening each time a new db connection (this may take some time).

     
    Sanil Joseph
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Andrei,
    Thanks for your reply...
    Actually I'am not creating multiple connections. The connection is getting created only once....
     
    Sanil Joseph
    Greenhorn
    Posts: 5
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Hi,
    I have reduced the response time further more.
    There are some methods called inside the loop where I create some objects and return them. I removed those methods and wrote the object creation there itself instead of in the objects. This saved me alot of time.
    I'm still not sure if that is a problem. As far i know...the object creations in separate methods are just matter of very few milliseconds.

    Please comment.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!