pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Mark Kirkwood <mark.kirkwood@catalyst.net.nz>
To: Ankit Kumar <ankitk@xebia.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: OutOfMemory hibernate scroll with 2M records | Postgresql 8.4 DB
Date: Tue, 22 Dec 2009 17:35:25 +1300
Message-ID: <4B304C8D.8000608@catalyst.net.nz> (raw)
In-Reply-To: <4B3047E7.9020901@xebia.com>
References: <4B3047E7.9020901@xebia.com>

Ankit Kumar wrote:
> Hi
>
> I am running a Criteria.scroll() on postgresql on a DB containing 2M 
> records. The memory keeps increasing and finally it generates an 
> OutOfMemoryException. Please can you advice how to fix this.
>
> *Postgresql DB version:* 8.4
> *Postgresql Driver Used:* postgresql-8.4-701.jdbc4.jar
>
> Some forums do mention that "/scroll/" is slow on Postgresql.
>
> Is this a known issue or we need to do something specific to make 
> scroll work on Postgresql?
>
> It appears the driver class is loading all entity objects in memory 
> and not releasing them as expected in a scroll operation.
>
>
> Appreciate any guidance/suggestion.
>
> *Exception StackTrace*:
> java.lang.OutOfMemoryError: Java heap space
>  
>

This link might be useful for you to look at:

https://forums.hibernate.org/viewtopic.php?p=2398604&sid=f277fe884089594fe39272f69b68e329

It would appear that you need to encourage Hibernate to use a cursor, 
instead of buffering the entire resultset in memory - I haven't looked 
too much at the hibernate docs (never used it before...) so I have no 
idea how to do this myself, but if I have time I'll dig a bit.

Do you have a self contained example to show us how you are setting up 
the scrollable resultset?

regards

Mark



view thread (5+ messages)  latest in thread

Message-ID: <4B304C8D.8000608@catalyst.net.nz>
Permalink:  ../4B304C8D.8000608@catalyst.net.nz/
Also on:    postgresql.org/message-id/4B304C8D.8000608@catalyst.net.nz

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: mark.kirkwood@catalyst.net.nz, ankitk@xebia.com
  Subject: Re: OutOfMemory hibernate scroll with 2M records | Postgresql 8.4 DB
  In-Reply-To: <4B304C8D.8000608@catalyst.net.nz>
  References: <4B3047E7.9020901@xebia.com> <4B304C8D.8000608@catalyst.net.nz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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