Re: java.lang.OutOfMemory Exception with a large number of inserts

From: "Rene Pijlman" <rene(at)lab(dot)applinet(dot)nl>
To: "Arsalan Zaidi" <azaidi(at)directi(dot)com>
Cc: <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: java.lang.OutOfMemory Exception with a large number of inserts
Date: 2001-10-04 08:12:56
Message-ID: BEELJGLKPCMDGFENPBPNCENODKAA.rene@lab.applinet.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

You wrote:
> Here's the offending loop. BTW, I messed up with the
> total number of rows, it's ~6,000,000, not 600,000.
[...]
> while(dbResult.next())

Unfortunately, PostgreSQL clients always retrieve the entire
resultset from the server before it is processed by the .next()
loop.

In your case this means that the 6.000.000 rows are first read
by the Java client into one huge ResultSet. This will no doubt
require much more than 50M of memory.

Can't you perform this operation in one or more SQL statements
or procedurally in PLSQL on the server, instead of retrieving
all data to the client?

Cheers,
René Pijlman

Browse pgsql-jdbc by date

  From Date Subject
Next Message Roger Oed 2001-10-04 08:41:39 JDBC 2.0
Previous Message Thomas Lockhart 2001-10-04 04:39:19 Re: Timestamp, fractional seconds problem