Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Databases / September 2004

Tip: Looking for answers? Try searching our database.

ResultSet.setFetchSize()

Thread view: 
mamin - 20 Sep 2004 09:45 GMT
When rs.setFetchSize(); should be used? Is it correct to use it after
executing query? For example:
ResultSet rs= db.query(.....)
......
rs.setFetchSize(1024);
while(rs.next()){...}
Joe Weinstein - 20 Sep 2004 15:57 GMT
> When rs.setFetchSize(); should be used? Is it correct to use it after
> executing query? For example:
> ResultSet rs= db.query(.....)
> ......
> rs.setFetchSize(1024);
> while(rs.next()){...}

Some drivers pay attention to that call, and others don't. Some of those that do,
need to know what your hint is before executing the first fetch.
   I would call it right after getting the result set. Also note that depending
on the type of result set (scrollable, updateable etc) it may or may not be
impossible for a driver to react in any valuable way to this call. Test your performance
to see if it's worth making the call.
   It's probably much more likely that making a call to Statement.setFetchSize()
would have the hoped-for affect. If a driver can use such a hint, it is more likely
to be able to use it then, before the query.

Joe Weinstein at BEA
mamin - 21 Sep 2004 09:00 GMT
Hmmm, it looks like nor ResultSet.SetFetchSize() nor Statement.SetFetchSize
works:( And I've no idea why.

> > When rs.setFetchSize(); should be used? Is it correct to use it after
> > executing query? For example:
[quoted text clipped - 14 lines]
>
> Joe Weinstein at BEA
JoeAtHome - 21 Sep 2004 23:20 GMT
> Hmmm, it looks like nor ResultSet.SetFetchSize() nor Statement.SetFetchSize
> works:( And I've no idea why.

  How do you know they don't work? I think maybe you are mistaking what these
methods are supposed to do. They are merely performance hints that don't change
anything about the *amount* of rows a result set provides. They simply tell the
driver to get that many rows at a time (instead of one-at-a-time) from the DBMS
so that every call to next() doesn't require a client-DBMS roundtrip.
  If you want to limit the *nmuber* of rows returned, the ideal behavior is to
tailor your SQL to get (only) what you want. As a last resort, you can try
Statement.setMaxRows() before the query.
Joe Weinstein at BEA

> > > When rs.setFetchSize(); should be used? Is it correct to use it after
> > > executing query? For example:
[quoted text clipped - 20 lines]
> >
> > Joe Weinstein at BEA


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.