This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Kubernetes in Action and have Marko Luksa on-line!
See this thread for details.
Win a copy of Kubernetes in Action this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Performance question  RSS feed

 
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
 
Ranch Hand
Posts: 1512
  • 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.
 
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
Boost this thread!