• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC ResultSet Size

 
Gurdershan Singh Bagga
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34974
379
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic