This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
The moose likes JDBC and Relational Databases and the fly likes Performance of fomatting string : Java vs Database. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Building Microservices this week in the Design forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Performance of fomatting string : Java vs Database. " Watch "Performance of fomatting string : Java vs Database. " New topic
Author

Performance of fomatting string : Java vs Database.

Ritesh Srivastava
Greenhorn

Joined: Jul 06, 2005
Posts: 26
I have a String which needs be sent to a stored procedure. Then this string is inserted in the database through the stored procedure. But the string needs to be formatted (say date formatting).

This formatting can be done either in the java program which later calls the stored procedure or in the stored procedure itself. Which way gives better performance?
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
I wouldn't worry about the performance of this, but rather the overall design. Formatting data is really not something that should be done in the DB, or for which DBs are well suited.
Ritesh Srivastava
Greenhorn

Joined: Jul 06, 2005
Posts: 26
Thanks for the reply. Yes I too agree that database should not be doing formatting. But I am still wondering which approach would be faster.
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32507
    
214

Originally posted by Ritesh Srivastava:
But I am still wondering which approach would be faster.

It depends. You would have to try it out to be sure.

I second Ulf on the performance not being the driving factor here. It is not likely to be the bottleneck of your application.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
steve souza
Ranch Hand

Joined: Jun 26, 2002
Posts: 862
I agree with the previous posters. Even if they wanted to answer they couldn't as it depends on too many factors. For example does the database run on a more powerful machine than the jvm or vice versa.


http://www.jamonapi.com/ - a fast, free open source performance tuning api.
JavaRanch Performance FAQ
Ulf Dittmer
Rancher

Joined: Mar 22, 2005
Posts: 42958
    
  73
A somewhat unrelated side issue is that JDBC is a string-based API anyway. Any data will be sent to the database as a string, not as (e.g.) a date. So if the formatting were done in the DB, then the date would be formatted to a string by JDBC, then sent to the DB, and then be re-formatted according to your rules (and then be parsed and stored by the DB in its own format, whatever that may be). So just based on that I'd guess that doing the formatting in Java has a chance of being faster.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Performance of fomatting string : Java vs Database.
 
jQuery in Action, 3rd edition