• 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

Db calls & performance

 
Ranch Hand
Posts: 128
MS IE Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to increase efficiency of a java program. I'm thinking a large number of db calls would make a performance hit, for ex: making a 1000 insert call's for inserting thousand records.

db calls do take time right?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Everything takes time.
Your first step should be to use a profiler to identify the bottlenecks (slow-performing operations) in your program. It's no use spending days optimizing database access if the bottleneck is elsewhere.
 
Allen Bandela
Ranch Hand
Posts: 128
MS IE Eclipse IDE Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please expand on that subject: profiler.
 
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's true, you should find the bottle neck and then resolve it rather than coming up with predictions.

Most of the time, the performance hit is from slow running SQL statements rather than the way JDBC is written. It won't be useful to optimize JDBC code if a query takes 10 seconds to run on the DBMS side.

Some JDBC performance tips are: Use connection pools. Under the right situations, use batch updates, reuse compiled PreparedStatement.
[ April 06, 2007: Message edited by: Chu Tan ]
 
Joe Ess
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sylvester James:
Can you please expand on that subject: profiler.



A profiler is an application like JProbe that gives you feedback like how long it takes to execute methods and how many object instances are created in a period of time.
A good place to start is the book Java Platform Performance. It covers the basics of how and what to measure performance-wise. As Chu says, there's plenty one can do to streamline JDBC. Try searching our performance forum for more on the subject.
BTW: Make sure your hardware is up to the task. If your CPU is 100% and there is no RAM and the disks are spinning like mad swapping back and forth, no amount of software tuning will make your app go faster.
 
Message for you sir! I think it is a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic