You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Torkjel Hongve (JIRA)" <ji...@apache.org> on 2015/11/15 00:01:11 UTC

[jira] [Commented] (DERBY-5765) Embedded doesn't clear warnings on ResultSet when moving to next row

    [ https://issues.apache.org/jira/browse/DERBY-5765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15005656#comment-15005656 ] 

Torkjel Hongve commented on DERBY-5765:
---------------------------------------

Still seen in 10.12.1.1. 

With largeish result sets that produce many warnings (like one per row), this becomes a major performance problem. Memory usage increases proportional to the result set size, and due to the way the warning chain is handled (a naive linked list implementation in SQLException), the time it takes to retrieve the result set grows quadratically. 

Example: 

Create a table with two columns and 200k rows as follows:
{code}
create table t (a integer, b integer);
insert into t (a, b) values (1, 1);
insert into t (a, b) values (1, null);
insert into t (a, b) values (2, 2);
insert into t (a, b) values (2, null);
...
insert into t (a, b) values (100000, 100000);
insert into t (a, b) values (100000, null);
{code}

Iterating the result set of the following query takes several minutes: 

{code}
select a, max(b) maxb from t group by a;
{code}

The source of the sql warnings is the max(b) expression, which will generate a warning whenever it encounters a null value, even though ignoring nulls is documented behaviour (http://db.apache.org/derby/docs/10.12/ref/rrefsqlj27781.html) 


> Embedded doesn't clear warnings on ResultSet when moving to next row
> --------------------------------------------------------------------
>
>                 Key: DERBY-5765
>                 URL: https://issues.apache.org/jira/browse/DERBY-5765
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.8.2.2
>            Reporter: Knut Anders Hatlen
>              Labels: derby_triage10_10
>         Attachments: ClearWarnings.java
>
>
> The javadoc for java.sql.ResultSet.getWarnings() says that the warning chain should be cleared automatically when a new row is read. The client driver does that, but the embedded driver does not.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)