I would have done so, had I written the application. Unfortunately, the application was written by somebody else. Putting the entire result set in memory is a bad idea and Postgres client should be changed, probably by adding some configuration options, like maximum memory that the client is allowed to consume and a "swap file". These options should be configurable per user, not system-wide. As I have said in my post, I do have a solution for my immediate problem but this slows things down: