Are you then trying to process the whole data set at once? I'm prettycertain the issue is your app, not pgsql, running out of memory.