Re: Out of memory error on huge resultset - Mailing list pgsql-jdbc

From Nic Ferrier
Subject Re: Out of memory error on huge resultset
Date
Msg-id 87adljzxw1.fsf@pooh-sticks-bridge.tapsellferrier.co.uk
Whole thread Raw
In response to Re: Out of memory error on huge resultset  (Barry Lind <barry@xythos.com>)
Responses Re: Out of memory error on huge resultset  (Aaron Mulder <ammulder@alumni.princeton.edu>)
cursor based result sets not updateable  (Dave Cramer <Dave@micro-automation.net>)
List pgsql-jdbc
Barry Lind <barry@xythos.com> writes:

> Nic Ferrier wrote:
>
> > So I'm simply transforming querys from:
> >
> >
> >     SELECT x FROM y WHERE z;
> >
> >
> > into
> >
> >     DECLARE jdbcXX CURSOR FOR $query ;
> >     FETCH FORWARD $fetchSize jdbcXX;
> >
>
> And when $query is:  "insert into foo values (...); select * from bar;"
>
> You will get:
> DECLARE jdbcXX CURSOR FOR insert into foo values (...);
> select * from bar;
> FETCH FORWARD $fetchSize jdbcXX;
>
> Which clearly isn't what you want.

That's a really good point Barry. I never do that so it's not
something I'd considered.

Isn't a solution to only do the to_cursor translation when the
statement given begins with "SELECT "?

I agree that it's far from perfect, but it will do for _most_ cases
won't it?


Interestingly, I don't think what you've speced above is even
possible with some databases is it? Another advantage of using
PostgreSQL is that you must properly terminate your SQL statements,
unlike with some commercial databases I could mention.


Nic

pgsql-jdbc by date:

Previous
From: "Bernd Brenner"
Date:
Subject: Re: pq_recvbuf: recv() failed: Connection reset by peer
Next
From: Aaron Mulder
Date:
Subject: Re: Out of memory error on huge resultset