Bug #18148 | setFetchSize() does not adhear to jdbc interface contract | ||
---|---|---|---|
Submitted: | 11 Mar 2006 3:35 | Modified: | 11 Mar 2006 4:42 |
Reporter: | Jeramyn Feucht | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | Connector / J | Severity: | S1 (Critical) |
Version: | Tested in 3.1,3.2,5.0 | OS: | Windows (Windows XP (Irrelevant)) |
Assigned to: | CPU Architecture: | Any |
[11 Mar 2006 3:35]
Jeramyn Feucht
[11 Mar 2006 3:36]
Jeramyn Feucht
one note related to bug 15321 but i could not change the status of that bug to open.
[11 Mar 2006 4:42]
Mark Matthews
The MySQL server doesn't have the ability before version 5.0 to even make this possible. It is not a limitation of the JDBC driver, there just isn't a way to make it work before MySQL-5.0 because of limitations in the network protocol and no support for "Cursors" for result sets. Streaming result sets only allow one open result set at a time on a given connection, which also doesn't adhere to the JDBC API (but which is also a trait shared with other vendors, some who open whole new connections for each new statement, and thus aren't capable of running transactions in this mode). That's why it's not the default for MySQL. In general, prior to MySQL-5.0, the JDBC driver is set "out of the box" for OLTP type applications, where result sets are smaller, and the aim is to reduce lock contention in the server. There is experimental support for fetching rows in batches (see the documentation for more details) when using Connector/J 5.0.1 (not yet released, see nightly snapshots at http://downloads.mysql.com/snapshots.php#connectorj) When using Connector/J 5.0.1 along with more recent builds of the MySQL server, you can add "useCursorFetch=true" to your JDBC url parameters, and the driver will fetch rows in batches of size setFetchSize() as defined in the JDBC API. One could also argue that the behavior _does_ follow the JDBC API, quoting from the APIDOCS for Statement.setFetchSize(): "Gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. The number of rows specified affects only result sets created using this statement. If the value specified is zero, then the hint is ignored. The default value is zero." It's only a _hint_. Driver vendors are allowed to ignore hints. The very reason that the wording is there is because there are quite a few vendors who can not adhere to this "contract" in all situations. I'm marking this as "Not a bug", because the functionality is there in C/J 5.0 when using the MySQL-5.0 server. If you find the functionality lacking, please reopen this bug with more details.
[27 Nov 2006 3:06]
Chris Wilper
I just wanted to point out that the JDBC Statement.setFetchSize contract also states: Throws: SQLException - if a database access error occurs, or the condition 0 <= rows <= this.getMaxRows() is not satisfied. So the Integer.MIN_VALUE (a negative number) workaround is actually not in-spec because it depends on the implementation to violate this expectation.
[15 May 2009 15:51]
Janarthanan Poornavel
Hi, I know I am very late to add comment to this bug. But please understand the fact, that you completely put all of us off by quoting that, the feature to configure fetchSize is experimental and went ahead to contradict that you are closing the bug since it is available in 5.0 connector. I am using pentaho pdi(one of your technology partners), which in its latest version does not believe in this theory and still uses the technique of streaming. When I am trying to move around large datasets(please read in millions), I am expecting a predictable way to configure the fetch size(leave it to me to figure how much heap I want for this). Please do not expect me to use a feature that you declared as experimental. I think, at least it would make sense for you to come back and declare that you are no more considering the feature implementation as experimental. I can ask my architect to open a ticket, since we have a platinum support, if you think that could help you to take this on a serious note.
[15 May 2009 16:09]
Janarthanan Poornavel
Hi, I know I am very late to add comment to this bug. But please understand the fact, that you completely put all of us off by quoting that, the feature to configure fetchSize is experimental and went ahead to contradict that you are closing the bug since it is available in 5.0 connector. I am using pentaho pdi(one of your technology partners), which in its latest version does not believe in this theory and still uses the technique of streaming. When I am trying to move around large datasets(please read in millions), I am expecting a predictable way to configure the fetch size(leave it to me to figure how much heap I want for this). Please do not expect me to use a feature that you declared as experimental. I think, at least it would make sense for you to come back and declare that you are no more considering the feature implementation as experimental. I can ask my architect to open a ticket, since we have a platinum support, if you think that could help you to take this on a serious note.
[16 May 2009 13:14]
Mark Matthews
The feature is experimental on the server, so if you're going to open a support issue, open it on the server. The JDBC driver has full support for it, but the caveats exist on the server side, which is why it's not enabled by default. It's not enabled be default, because many frameworks, and application code (mistakenly) call setFetchSize() whether they need to or not.
[16 May 2009 13:17]
Mark Matthews
> So the Integer.MIN_VALUE (a negative number) workaround is actually not in-spec > because it > depends on the implementation to violate this expectation. There are spec-compliant methods on com.mysql.jdbc.Statement to enable/disable streaming results (enable/disableStreamingResults()). On the other hand, actually using streaming results creates some non-JDBC compliant behavior, in that you can't have more than one in-progress Statement per-connection.
[18 May 2009 10:44]
Janarthanan Poornavel
Matthew, Thanks a lot. If it is going to be a enhancement from server side, I presume its going to be a long drawn process. To me Issue is still not solved, I have to see the jdbc interface and the server in unison. Do you have any performance numbers that can be shared with me, when the connector handles large dataset in such fashion. Would you be able to tell me an alternative methodology to improve the performance of result streaming ?