pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Resultset holdability
7+ messages / 2 participants
[nested] [flat]

* Resultset holdability
@ 2005-10-21 15:46  Geert Bevin <gbevin@uwyn.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Geert Bevin @ 2005-10-21 15:46 UTC (permalink / raw)
  To: pgsql-jdbc

Hello,

I have a resultset that has many rows with bytea data.

It looks like me that when I iterate through the rows, the previous  
rows are only garbage collectable when the resultset is closed, even  
if I setup the statement like this:
statement.setFetchDirection(ResultSet.FETCH_FORWARD);
statement.setFetchSize(1);

Since it's bytea data, this fills up the memory very quickly. Any  
thoughts on how to reduce this memory overhead and have the resultset  
discard any previously fetched data?

Thanks for the help,

Geert

--
Geert Bevin                       Uwyn bvba
"Use what you need"               Avenue de Scailmont 34
http://www.uwyn.com               7170 Manage, Belgium
gbevin[remove] at uwyn dot com    Tel +32 64 84 80 03

PGP Fingerprint : 4E21 6399 CD9E A384 6619  719A C8F4 D40D 309F D6A9
Public PGP key  : available at servers pgp.mit.edu, wwwkeys.pgp.net





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Resultset holdability
@ 2005-10-21 21:02  Oliver Jowett <oliver@opencloud.com>
  parent: Geert Bevin <gbevin@uwyn.com>
  0 siblings, 2 replies; 7+ messages in thread

From: Oliver Jowett @ 2005-10-21 21:02 UTC (permalink / raw)
  To: Geert Bevin <gbevin@uwyn.com>; +Cc: pgsql-jdbc

Geert Bevin wrote:

> I have a resultset that has many rows with bytea data.
> 
> It looks like me that when I iterate through the rows, the previous  
> rows are only garbage collectable when the resultset is closed, even  if 
> I setup the statement like this:
> statement.setFetchDirection(ResultSet.FETCH_FORWARD);
> statement.setFetchSize(1);
> 
> Since it's bytea data, this fills up the memory very quickly. Any  
> thoughts on how to reduce this memory overhead and have the resultset  
> discard any previously fetched data?

What driver version are you using?
What server version are you using?
Have you turned autocommit off?

-O



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Resultset holdability
@ 2005-10-21 21:33  Geert Bevin <gbevin@uwyn.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  1 sibling, 1 reply; 7+ messages in thread

From: Geert Bevin @ 2005-10-21 21:33 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc


On 21-okt-05, at 23:02, Oliver Jowett wrote:

> Geert Bevin wrote:
>
>
>> I have a resultset that has many rows with bytea data.
>> It looks like me that when I iterate through the rows, the  
>> previous  rows are only garbage collectable when the resultset is  
>> closed, even  if I setup the statement like this:
>> statement.setFetchDirection(ResultSet.FETCH_FORWARD);
>> statement.setFetchSize(1);
>> Since it's bytea data, this fills up the memory very quickly. Any   
>> thoughts on how to reduce this memory overhead and have the  
>> resultset  discard any previously fetched data?

Btw, it definitely is the resultset, since instead of using it to  
iterate through the results I tried doing it by running a prepared  
statement for each row and obtaining the results like this. The  
frontend logic remained the same and I have no memory problems  
anymore, except that there are an awful lot of queries now :-(

> What driver version are you using?

I tried with both 8.0-313 JDBC 3 and 8.1dev-402 JDBC 3

> What server version are you using?

8.0.3

> Have you turned autocommit off?

No


--
Geert Bevin                       Uwyn bvba
"Use what you need"               Avenue de Scailmont 34
http://www.uwyn.com               7170 Manage, Belgium
gbevin[remove] at uwyn dot com    Tel +32 64 84 80 03

PGP Fingerprint : 4E21 6399 CD9E A384 6619  719A C8F4 D40D 309F D6A9
Public PGP key  : available at servers pgp.mit.edu, wwwkeys.pgp.net





^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Resultset holdability
@ 2005-10-21 21:33  Oliver Jowett <oliver@opencloud.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  1 sibling, 1 reply; 7+ messages in thread

From: Oliver Jowett @ 2005-10-21 21:33 UTC (permalink / raw)
  To: Geert Bevin <gbevin@uwyn.com>; +Cc: pgsql-jdbc

Oliver Jowett wrote:
> Geert Bevin wrote:
> 
>> I have a resultset that has many rows with bytea data.
>>
>> It looks like me that when I iterate through the rows, the previous  
>> rows are only garbage collectable when the resultset is closed, even  
>> if I setup the statement like this:
>> statement.setFetchDirection(ResultSet.FETCH_FORWARD);
>> statement.setFetchSize(1);
>>
>> Since it's bytea data, this fills up the memory very quickly. Any  
>> thoughts on how to reduce this memory overhead and have the resultset  
>> discard any previously fetched data?
> 
> 
> What driver version are you using?
> What server version are you using?
> Have you turned autocommit off?

One more:

Is the statement/resultset TYPE_FORWARD_ONLY?

-O



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Resultset holdability
@ 2005-10-21 21:57  Geert Bevin <gbevin@uwyn.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Geert Bevin @ 2005-10-21 21:57 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

> One more:
>
> Is the statement/resultset TYPE_FORWARD_ONLY?

Yes.

-- 
Geert Bevin                       Uwyn bvba
"Use what you need"               Avenue de Scailmont 34
http://www.uwyn.com               7170 Manage
gbevin[remove] at uwyn dot com    Tel +32 64 84 80 03

PGP Fingerprint : 4E21 6399 CD9E A384 6619  719A C8F4 D40D 309F D6A9
Public PGP key  : available at servers pgp.mit.edu, wwwkeys.pgp.net






^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Resultset holdability
@ 2005-10-21 23:01  Oliver Jowett <oliver@opencloud.com>
  parent: Geert Bevin <gbevin@uwyn.com>
  0 siblings, 1 reply; 7+ messages in thread

From: Oliver Jowett @ 2005-10-21 23:01 UTC (permalink / raw)
  To: Geert Bevin <gbevin@uwyn.com>; +Cc: pgsql-jdbc

Geert Bevin wrote:

>> Have you turned autocommit off?
> 
> No

The driver won't use portal-based resultsets unless you turn off 
autocommit. This is because it can't create the equivalent of a WITH 
HOLD cursor via protocol-level portals, so any portal created will be 
closed at the end of the creating transaction. With autocommit on, the 
transaction ends immediately after statement execution, so using a 
portal is pointless.

Otherwise it sounds like you meet all the requirements (V3 protocol, 
TYPE_FORWARD_ONLY, and fetchsize > 0).

-O



^ permalink  raw  reply  [nested|flat] 7+ messages in thread

* Re: Resultset holdability
@ 2005-10-21 23:10  Geert Bevin <gbevin@uwyn.com>
  parent: Oliver Jowett <oliver@opencloud.com>
  0 siblings, 0 replies; 7+ messages in thread

From: Geert Bevin @ 2005-10-21 23:10 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

Thanks a lot Oliver, turning off autocommit seems to work :-)

On 22-okt-05, at 01:01, Oliver Jowett wrote:

> Geert Bevin wrote:
>
>
>>> Have you turned autocommit off?
>>>
>> No
>>
>
> The driver won't use portal-based resultsets unless you turn off  
> autocommit. This is because it can't create the equivalent of a  
> WITH HOLD cursor via protocol-level portals, so any portal created  
> will be closed at the end of the creating transaction. With  
> autocommit on, the transaction ends immediately after statement  
> execution, so using a portal is pointless.
>
> Otherwise it sounds like you meet all the requirements (V3  
> protocol, TYPE_FORWARD_ONLY, and fetchsize > 0).
>
> -O
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 2: Don't 'kill -9' the postmaster
>
>

--
Geert Bevin                       Uwyn bvba
"Use what you need"               Avenue de Scailmont 34
http://www.uwyn.com               7170 Manage, Belgium
gbevin[remove] at uwyn dot com    Tel +32 64 84 80 03

PGP Fingerprint : 4E21 6399 CD9E A384 6619  719A C8F4 D40D 309F D6A9
Public PGP key  : available at servers pgp.mit.edu, wwwkeys.pgp.net





^ permalink  raw  reply  [nested|flat] 7+ messages in thread


end of thread, other threads:[~2005-10-21 23:10 UTC | newest]

Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-10-21 15:46 Resultset holdability Geert Bevin <gbevin@uwyn.com>
2005-10-21 21:02 ` Oliver Jowett <oliver@opencloud.com>
2005-10-21 21:33   ` Geert Bevin <gbevin@uwyn.com>
2005-10-21 23:01     ` Oliver Jowett <oliver@opencloud.com>
2005-10-21 23:10       ` Geert Bevin <gbevin@uwyn.com>
2005-10-21 21:33   ` Oliver Jowett <oliver@opencloud.com>
2005-10-21 21:57     ` Geert Bevin <gbevin@uwyn.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox