Here is the test case.
It fails with java.lang.OutOfMemoryError: Java heap space exception.

Increasing value of N will kill any increase in -Xmx parameter. It
seems that the intermediate results are accumulated in memory
instead of creating a temporary table.


   @Test
    public void memory() throws Exception {

        int N = 1000;

        Class.forName("org.h2.Driver");
        ca = DriverManager.getConnection("jdbc:h2:c:\\temp\\h2");
        Statement statement = ca.createStatement();
        statement.execute("DROP TABLE one if exists");
        statement.execute("DROP TABLE two if exists");
        statement.execute("DROP TABLE three if exists");
        statement.execute("CREATE TABLE one(id INT )");

        PreparedStatement ins = ca.prepareStatement("insert into one
values(?)");

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 1000; j++) {
                ins.setInt(1, i * 1000 + j);
                ins.addBatch();
            }
            ins.executeBatch();
        }


        String sql = "create table two as select id from one group by
id";
        boolean success = statement.execute(sql);

        sql = "create table three as select id from one group by id
order by id";
        statement.execute(sql);

    }

PS. The last select clause "order by" does not make sense for standard
H2 tables but it is important for our own customized extension of the
class RegularTable.

Sincerely,
Pavel

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to