pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Zoltan Boszormenyi <zboszor@dunaweb.hu>
To: pgsql-performance@postgresql.org
Subject: psql -A (unaligned format) eats too much memory
Date: Mon, 05 Jun 2006 00:01:24 +0200
Message-ID: <44835834.2020309@dunaweb.hu> (raw)

Hi,

I just noticed that psql's unformatted output uses too much
memory. Is it normal? It seems that psql draws all records
of a query off the server before it displays or writes the output.
I would expect this only with formatted output.

Problem is, I have an export that produces 500'000+ records
which changes frequently. Several (20+) sites run this query
nightly with different parameters and download it. The SELECTs
that run in psql -A -t -c '...' may overlap and the query that runs
in less than 1.5 minutes if it's the only one at the time may take
3+ hours if ten such queries overlap. The time is mostly spent
in swapping, all psql processes take up 300+ MB, so the 1GB
server is brought to its knees quickly, peek swap usage is 1.8 GB.
I watched the progress in top and the postmaster processes finished
their work in about half an hour (that would still be acceptable)
then the psql processes started eating up memory as they read
the records.

PostgreSQL 8.1.4 was used on RHEL3.

Is there a way to convince psql to use less memory in unformatted
mode? I know COPY will be able to use arbitrary SELECTs
but until then I am still stuck with redirecting psql's output.

Best regards,
Zoltán Böszörményi




view thread (6+ messages)  latest in thread

Message-ID: <44835834.2020309@dunaweb.hu>
Permalink:  ../44835834.2020309@dunaweb.hu/
Also on:    postgresql.org/message-id/44835834.2020309@dunaweb.hu

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: zboszor@dunaweb.hu
  Subject: Re: psql -A (unaligned format) eats too much memory
  In-Reply-To: <44835834.2020309@dunaweb.hu>

* 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