> 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