Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 55C8D64FD08 for ; Wed, 3 Dec 2008 12:14:42 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 36114-02 for ; Wed, 3 Dec 2008 12:14:36 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mx00.pub.collaborativefusion.com (mx00.pub.collaborativefusion.com [206.210.89.199]) by mail.postgresql.org (Postfix) with ESMTP id F27D564FCE1 for ; Wed, 3 Dec 2008 12:14:34 -0400 (AST) Received: from vanquish.ws.pitbpa0.priv.collaborativefusion.com (vanquish.ws.pitbpa0.priv.collaborativefusion.com [192.168.2.162]) (SSL: TLSv1/SSLv3,256bits,AES256-SHA) by wingspan with esmtp; Wed, 03 Dec 2008 11:14:30 -0500 id 00056414.000000004936B066.0000F2AA Date: Wed, 3 Dec 2008 11:14:30 -0500 From: Bill Moran To: Matthew Wakeling Cc: pgsql-performance@postgresql.org Subject: Re: Postgres using more memory than it should Message-Id: <20081203111430.b794be92.wmoran@collaborativefusion.com> In-Reply-To: References: Organization: Collaborative Fusion X-Mailer: Sylpheed 2.5.0 (GTK+ 2.12.11; i386-portbld-freebsd7.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200812/21 X-Sequence-Number: 32057 In response to Matthew Wakeling : > > Hi. I have a problem on one of our production servers. A fairly > complicated query is running, and the backend process is using 30 GB of > RAM. The machine only has 32GB, and is understandably swapping like crazy. > My colleague is creating swap files as quickly as it can use them up. > > The work_mem setting on this machine is 1000MB, running Postgres 8.3.0. If your query it dealing with a lot of data, it could easily use 1G per sort operation. If there are a lot of sorts (more than 32) you'll end up with this problem. 1G is probably too much memory to allocate for work_mem. -- Bill Moran Collaborative Fusion Inc. http://people.collaborativefusion.com/~wmoran/ wmoran@collaborativefusion.com Phone: 412-422-3463x4023 **************************************************************** IMPORTANT: This message contains confidential information and is intended only for the individual named. If the reader of this message is not an intended recipient (or the individual responsible for the delivery of this message to an intended recipient), please be advised that any re-use, dissemination, distribution or copying of this message is prohibited. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission. ****************************************************************