aspose file tools*
The moose likes JDBC and the fly likes JDBC ResultSet Size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC ResultSet Size" Watch "JDBC ResultSet Size" New topic
Author

JDBC ResultSet Size

Gurdershan Singh Bagga
Greenhorn

Joined: Oct 02, 2008
Posts: 8
Hi All,

I am having a doubt in using JDBC cache management. The issue is which of the 2 ways we should use.

1.

2.

Thedifference between the 2 ways is that the ResultSet in 1 contains all rows while in 2 it contains the specified range of rows only. I tried to find the memory size of resultset object and in both cases its comming same.
So Kindly suggest me which one of the following is better.

Thanks in advance...
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
It depends on your table setup and how many data has to be manipulated and compared.

The first option (the inner select) will work slower and slower the more data is in the table, since the sql server does all the sorting. But in general sql servers are much faster processing data than if you did it in java.

I personally always tend to have the server do all the work to keep my java code as clean as possible.

Also, you might want to check into JDBCSupport


JDBCSupport - An easy to use, light-weight JDBC framework -
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30764
    
156

Sebastian Janisch wrote:The first option (the inner select) will work slower and slower the more data is in the table, since the sql server does all the sorting. But in general sql servers are much faster processing data than if you did it in java.

The second one has a scaling issue too. It will return an increasingly higher percentage over useless data from the database to the application. In my experience, this performance hit is worse than the one on the query.

I would go with option #1. Also, option #1 can be tuned slightly - use a "?" instead of adding the maximum/minimum number to the string. That way the prepared statement can be reused.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC ResultSet Size