Re: [RFC] How about changing the default value of defaultRowFetchSize? - Mailing list pgsql-jdbc

From Jorge Solórzano
Subject Re: [RFC] How about changing the default value of defaultRowFetchSize?
Date
Msg-id CA+cVU8NZYCzUwWC17DtY91Gom_StG=yQZvtATN82rddJLp6HtA@mail.gmail.com
Whole thread Raw
In response to Re: [RFC] How about changing the default value of defaultRowFetchSize?  (Mark Rotteveel <mark@lawinegevaar.nl>)
Responses Re: [RFC] How about changing the default value ofdefaultRowFetchSize?  ("Tsunakawa, Takayuki" <tsunakawa.takay@jp.fujitsu.com>)
List pgsql-jdbc
On Thu, Oct 20, 2016 at 11:55 AM, Mark Rotteveel <mark@lawinegevaar.nl> wrote:
On 20-10-2016 19:30, Jorge Solórzano wrote:
​So if the driver internally handle fetch size 0 == fetch size 100,
that's what i call an hidden inconsistent behavior.

Don't get me wrong, it make sense to switch ​defaultRowFetchSize to
"100", but a call to getFetchSize() should be == 100, not 0.

And that is how it should work, however according to the JDBC specification (or at least: that is how I read it), Statement.setFetchSize(0) means "use driver default fetch size".

To how I read the api (http://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html#setFetchSize(int)):

"​If the value specified is zero, then the hint is ignored. The default value is zero."

It don't really said "use default fetch size", it said the hint is ignored. IMO the api is a little ambiguous but the api and specification in "13.5 Performance Hints" reads:
The methods getFetchDirection and getFetchSize return the current value of the
hints. If either of these methods is called before the corresponding setter method has
been called, the value returned is implementation-defined.


​So is up to drivers choice what to return as "default"​
 
​if a setFetchSize​ is not called, so again IMO it should return 100 not 0.

Anyway, as Dave mentioned, this is just a "hint", and most apps need a certain scenario to actually use it (autocommit=off, type_forward_only, single statement). "What we do inside the driver is our business" is fine as long as you stick with the standard.



On the other hand, drivers are also free to ignore fetch size hints.

Mark
--
Mark Rotteveel

pgsql-jdbc by date:

Previous
From: Mark Rotteveel
Date:
Subject: Re: [RFC] How about changing the default value ofdefaultRowFetchSize?
Next
From: Brad DeJong
Date:
Subject: setCharacterStream(int, Reader)