Re: JDBC setFetchSize(n) ??

From: Wolf 'n Pinguin <duif.op.spijkers_at_planet.nl>
Date: 12 Jan 2002 15:50:13 GMT
Message-ID: <01c19b80$af509ea0$5be479c3_at_nentj001wxs>


Isma <Ismael_at_NOSPAMiballo.com> schreef in artikel <a1mpdi$7l1$1_at_sunnews.cern.ch>...
> Hi,
>
> I read in the documentation that setFetchSize(n)= Gives the JDBC driver a
> hint as to the number of rows that should be fetched from the database
when
> more rows are needed for this result set. But I don't understand well.
> Could it improve the speeed that Oracle takes to fetch results ?
> What is the best choice for n then ?

setFetchSize set the number of rows that should be fetched in one read operation. These rows are stored in JDBC memory. Standard n=1 . With for example setFetchSize(100), JDBC get 100 rows in 1 read, thus reducing the number of times Oracle has to be queried for new rows. Keep in mind that the larger n, the larger the memory use of your application.

The best size for n depends on your application. If you access small tables, or use very specific queries which return little record, then you won't need to use setFetchSize. If you loop through large tables, or execute queries returning large resultsets, you might want to increase the fetch size. I have obtained a 25% performance gain by using setFetchSize(100) for an application looping through a table containing appprox. a million records.
I would recommend experimenting with setFetchSize, to see what your best value for n is.

Hth, Ide Nentjes Received on Sat Jan 12 2002 - 16:50:13 CET

Original text of this message