Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id A40B164FD47 for ; Wed, 3 Dec 2008 12:24:17 -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 36970-08 for ; Wed, 3 Dec 2008 12:24:15 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.gransy.com (nathalia.gransy.com [82.208.29.194]) by mail.postgresql.org (Postfix) with ESMTP id 2F3BC64FD09 for ; Wed, 3 Dec 2008 12:24:14 -0400 (AST) Received: from localhost (localhost [127.0.0.1]) by mail.gransy.com (Postfix) with ESMTP id CA98C7AC306; Wed, 3 Dec 2008 17:24:11 +0100 (CET) Received: from mail.gransy.com ([127.0.0.1]) by localhost (nathalia.gransy.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cFMwUcoEGGA9; Wed, 3 Dec 2008 17:24:11 +0100 (CET) Received: from anastacia.gransy.com (anastacia.gransy.com [89.187.130.100]) by mail.gransy.com (Postfix) with ESMTP id AD80C7AC305; Wed, 3 Dec 2008 17:24:11 +0100 (CET) Received: from sq.gransy.com (localhost [127.0.0.1]) by anastacia.gransy.com (Postfix) with ESMTP id 384FE320445; Wed, 3 Dec 2008 17:25:12 +0100 (CET) Received: from 89.102.139.23 (SquirrelMail authenticated user tv@fuzzy.cz) by sq.gransy.com with HTTP; Wed, 3 Dec 2008 17:25:12 +0100 (CET) Message-ID: <61517.89.102.139.23.1228321512.squirrel@sq.gransy.com> In-Reply-To: References: Date: Wed, 3 Dec 2008 17:25:12 +0100 (CET) Subject: Re: Postgres using more memory than it should From: tv@fuzzy.cz To: "Matthew Wakeling" Cc: pgsql-performance@postgresql.org User-Agent: SquirrelMail/1.4.10a MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-2 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal 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/22 X-Sequence-Number: 32058 > > 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. Are you aware that this is a per-session / per-sort settings? That means, if you have 10 sessions, each of them running query with 2 sort steps in the plan, it may occupy up to 20 GB of RAM (if both sorts use the whole 1GB of RAM). regards Tomas