X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id DF3479FA5BA for ; Sun, 4 Jun 2006 19:34:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 60079-06 for ; Sun, 4 Jun 2006 19:34:44 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from linux.dunaweb.hu (linux.dunaweb.hu [62.77.196.1]) by postgresql.org (Postfix) with ESMTP id 80A159F9316 for ; Sun, 4 Jun 2006 19:34:43 -0300 (ADT) Received: from localhost (linux.dunaweb.hu [127.0.0.1]) by linux.dunaweb.hu (Postfix) with ESMTP id 2EB858E059C for ; Mon, 5 Jun 2006 00:01:23 +0200 (CEST) Received: from linux.dunaweb.hu ([127.0.0.1]) by localhost (linux.dunaweb.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07882-07 for ; Mon, 5 Jun 2006 00:01:22 +0200 (CEST) Received: from [81.17.177.202] (host-81-17-177-202.dunaweb.hu [81.17.177.202]) by linux.dunaweb.hu (Postfix) with ESMTP id 805D98E066B for ; Mon, 5 Jun 2006 00:01:22 +0200 (CEST) Message-ID: <44835834.2020309@dunaweb.hu> Date: Mon, 05 Jun 2006 00:01:24 +0200 From: Zoltan Boszormenyi User-Agent: Thunderbird 1.5.0.2 (X11/20060501) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: psql -A (unaligned format) eats too much memory Content-Type: text/plain; charset=ISO-8859-2; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Scanned: amavisd-new at dunaweb.hu X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/33 X-Sequence-Number: 19390 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