• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Performance question

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Which is more efficient (when reading select statement's resultset):
ResultSet.getString(int columnNumber)
or

ResultSet.getString(String columnName)?
It would seem that the first would have better performance but what do you think?
Greetings,
Jukka
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct, the fist one should be faster. It can be ian issue though if the table structure changes. i.e if the ordering of the columns changes.
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jukka Palom�ki:
Hi!
Which is more efficient (when reading select statement's resultset):
ResultSet.getString(int columnNumber)
or

ResultSet.getString(String columnName)?
It would seem that the first would have better performance but what do you think?
Greetings,
Jukka

The performance gain in the most extreme cases could probably not be detected. But for the readability and ease of maintenance factor, I highly recommend using ResultSet.getString(String columnName). Instead of trying to tweek microseconds off your program execution, if your concerned about performance, it is better to look at using the jdbc interface correctly ( like tips from this link ). If you still notice poor performance, use a profiler to see where the real bottlenecks are.
Jamie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic