File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Performance Issues with next statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Performance Issues with next statement " Watch "Performance Issues with next statement " New topic

Performance Issues with next statement

matt alberty

Joined: May 27, 2005
Posts: 6
In my code I use a while loop and next method on my result set. However, in this case it is taking upwards of 2 seconds to execute the next statement. Any ideas? The result set is only 4 rows. Am I not understanding exactly what the next method on the resultSet object is doing. It seems as if from the performance this is actually where the databse is getting queried.
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333
Depending on your driver and database and any use of Statement.setFetchSize(), your driver may or may not be going across the network to the database to retrieve additional rows. Again, depending on your driver and database, this might require re-execution of the query. However, on most modern databases with adequate hardware, even with a big fetch size, the worst-case time for an execution of next() ought to be well under a 10th of a second (and with a large fetch size, most execution of next() should be under 1 millesecond).
Paul Clapham

Joined: Oct 14, 2005
Posts: 19864

Does your complaint apply only to the first call to "next()" or to all of them?
matt alberty

Joined: May 27, 2005
Posts: 6
The first call. At this point it's looking like it is a database issue.
I agree. Here's the link:
subject: Performance Issues with next statement
It's not a secret anymore!