This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JDBC and the fly likes limit result through JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "limit result through JDBC" Watch "limit result through JDBC" New topic

limit result through JDBC

avihai marchiano
Ranch Hand

Joined: Jan 10, 2007
Posts: 342

I need to go other around 100,000 rows (row has 7 columns from join between tables) in bulk of 500-1000, do my process (around 20 sec for bulk) and take additional bulk ....

My question:

from performance perspective should i leave the result set open or for each bulk create result set and set beginning (by absolute ) at the end of the last bulk row?

I understand that when you use "absolute" the database iterate over all rows until this point , dosnt the database has any algorithm to do this without iterate over all rows?

Thank you
Arunkumar Subramaniam

Joined: Apr 08, 2009
Posts: 8

you can use SQL cached row result set for achive your goal

like :

Arunkumar S
avihai marchiano
Ranch Hand

Joined: Jan 10, 2007
Posts: 342
If you have 1000 rows in the resultset, so it will copy all rows?
Jeanne Boyarsky
internet detective

Joined: May 26, 2003
Posts: 30085

Or you could use the SQL query itself to only return the rows you want to each connection is independent. Then you don't have to worry about using resources between requests. You could use rownum or the primary key of your table in the query.

[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:
subject: limit result through JDBC
Similar Threads
Performance issue if I do not retrieve the rest of result set
How come I know number of rows in a Result Set ?
Passing array of objects......ResultSet
Hibernate 3.x and Data Dump
Fetching size limitted rows from a large database table