Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 13AA41D3FDD9 for ; Thu, 1 Mar 2012 21:17:44 -0400 (AST) Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1S3H7u-0007w9-UA for pgsql-performance@postgresql.org; Fri, 02 Mar 2012 01:17:43 +0000 X-Originating-IP: 217.70.178.132 Received: from mfilter5-d.gandi.net (mfilter5-d.gandi.net [217.70.178.132]) by relay3-d.mail.gandi.net (Postfix) with ESMTP id B9B3AA808E; Fri, 2 Mar 2012 02:17:18 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter5-d.gandi.net Received: from relay3-d.mail.gandi.net ([217.70.183.195]) by mfilter5-d.gandi.net (mfilter5-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id zzu2iqrwcvn7; Fri, 2 Mar 2012 02:17:17 +0100 (CET) X-Originating-IP: 98.27.54.176 Received: from [192.168.10.146] (cpe-098-027-054-176.nc.res.rr.com [98.27.54.176]) (Authenticated sender: adsend@dunslane.net) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 5DA7BA8087; Fri, 2 Mar 2012 02:17:16 +0100 (CET) Message-ID: <4F501F9A.4080905@dunslane.net> Date: Thu, 01 Mar 2012 20:17:14 -0500 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0) Gecko/20120131 Thunderbird/10.0 MIME-Version: 1.0 To: Claudio Freire CC: Peter van Hardenberg , postgres performance list Subject: Re: PG as in-memory db? How to warm up and re-populate buffers? How to read in all tuples into memory? References: <4F4A4DD6.6090904@squeakycode.net> <4F4A861A.3000301@squeakycode.net> <4F500163.9090200@dunslane.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201203/39 X-Sequence-Number: 46489 On 03/01/2012 07:58 PM, Claudio Freire wrote: > On Thu, Mar 1, 2012 at 9:28 PM, Peter van Hardenberg wrote: >>> Setting work_mem to hundreds of MB in a 4G system is suicide. Tens >>> even is dangerous. >>> >> Why do you say that? We've had work_mem happily at 100MB for years. Is >> there a particular degenerate case you're concerned about? > Me too. > > But I've analyzed the queries I'll be sending to the database and I've > carefully bound the effective amount of memory used given the load > I'll be experiencing. > > Saying that it should be set to 100M without consideration for those > matters is the suicide part. work_mem applies to each sort operation. > Suppose, just for the sake of argument, that each connection is > performing 5 such sorts (ie, 5 joins of big tables - not unthinkable), > then suppose you have your max_connections to the default of 100, then > the system could request as much as 50G of ram. > > I set work_mem higher in my database system since I *know* most of the > connections will not perform any merge or hash joins, nor will they > sort the output, so they won't use work_mem even once. The ones that > will, I have limited on the application side to a handful, hence I > *know* that 50G theoretical maximum will not be reached. > > Can the OP say that? I have no reason to think so. Hence I don't > suggest 100M is OK on a 4G system. Well, obviously you need to know your workload. Nobody said otherwise. cheers andrew