问题
Mysql driver has options to set so that resultset will not be read completely in memory as in here http://dev.mysql.com/doc/connector-j/en/connector-j-reference-implementation-notes.html#ResultSet.
Is there an equivalent option for H2?
Thanks,
回答1:
H2 currently does not support server side cursors. However, it buffers large result sets to disk (as a separate file, or as a temporary table). The disadvantage is speed, but it should not be a memory usage problems.
You can set the size of the when H2 will buffer to disk using set max_memory_rows. You can append that to the database URL: jdbc:h2:~/test;max_memory_rows=100000.
A workaround is usually to use "keyset paging" as described in the presentation "Pagination Done the Right Way". That would mean running multiple queries instead of one.
My plan is to implement server side cursors in H2 in the next months.
来源:https://stackoverflow.com/questions/24787119/how-to-set-h2-to-stream-resultset