Server side cursors

18 views
Skip to first unread message

Franklin Schmidt

unread,
Nov 19, 2009, 5:28:24 PM11/19/09
to h2-da...@googlegroups.com
When do you expect to implement server side cursors? My application
needs this because it reads from a long result set until certain
conditions are met and reading the entire result is too slow.

Thomas Mueller

unread,
Nov 22, 2009, 1:10:43 PM11/22/09
to h2-da...@googlegroups.com
Hi,

> When do you expect to implement server side cursors?

It's in the roadmap: http://www.h2database.com/html/roadmap.html
However I don't know when it will be implemented; maybe this year.

> My application needs this because it reads from a long result set until certain
> conditions are met and reading the entire result is too slow.

Why can't you set the condition in the query (maybe using a Java function)?

Regards,
Thomas

fschmidt

unread,
Dec 9, 2009, 12:27:49 AM12/9/09
to H2 Database
On Nov 22, 11:10 am, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:
>
> > My application needs this because it reads from a long result set until certain
> > conditions are met and reading the entire result is too slow.
>
> Why can't you set the condition in the query (maybe using a Java function)?

There are many cases when this won't work. For example, read records
until the sum of a column exceeds a limit.

Thomas Mueller

unread,
Dec 12, 2009, 3:32:57 AM12/12/09
to h2-da...@googlegroups.com
Hi,

> There are many cases when this won't work.  For example, read records
> until the sum of a column exceeds a limit.

I'm not saying server side cursors is not imporant (it is!), but this
problem you describe can be solved without server side cursors:

drop table test;
create table test(x int primary key) as select x from system_range(1, 100);
set @sum = 0;
select x, @sum := @sum + x as sum from test where @sum < 10 order by x;

This will select one row too much. If this is a problem, use:

select x, @sum as sum from test where (@sum := @sum + x) < 10 order by x;

Anyway, I have already started to implement server side cursors, this
is now very high on the list.

Regards,
Thomas
Reply all
Reply to author
Forward
0 new messages