Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 6C787B5D8C5 for ; Wed, 10 Aug 2011 16:28:01 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 75610-05 for ; Wed, 10 Aug 2011 19:27:54 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 6C0E1B5D80A for ; Wed, 10 Aug 2011 16:27:54 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id p7AJRqvC016359; Wed, 10 Aug 2011 15:27:52 -0400 (EDT) To: =?UTF-8?B?QWxleGlzIEzDqi1RdcO0Yw==?= cc: pgsql-performance@postgresql.org Subject: Re: Autovacuum running out of memory In-reply-to: References: <13854.1312996666@sss.pgh.pa.us> <15771.1313002463@sss.pgh.pa.us> Comments: In-reply-to =?UTF-8?B?QWxleGlzIEzDqi1RdcO0Yw==?= message dated "Wed, 10 Aug 2011 15:08:49 -0400" Date: Wed, 10 Aug 2011 15:27:51 -0400 Message-ID: <16358.1313004471@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.711 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RP_MATCHES_RCVD=-0.811 X-Spam-Level: X-Archive-Number: 201108/131 X-Sequence-Number: 44578 =?UTF-8?B?QWxleGlzIEzDqi1RdcO0Yw==?= writes: > On Wed, Aug 10, 2011 at 2:54 PM, Tom Lane wrote: >> Hmph. Is there other stuff being run on the same instance? Are there a >> whole lot of active PG processes? Maybe Amazon isn't really giving you >> a whole 8GB, or there are weird address space restrictions in the EC2 >> environment. Anyway I think I'd suggest reducing shared_buffers to 1GB >> or so. > Done and that fixed it. Thanks. > Now this is counter-intuitive (so much for intuition). > Any pointers to educate myself on why more shared buffers is > detrimental? My guess is that it's an address space restriction at bottom. Postgres starts (on typical systems) with program text at the beginning of its address space, static data after that, a large hole in the middle, and stack up at the top. Then the shared memory block gets allocated somewhere in the hole, at a spot that's more or less at the whim of the OS. If a Postgres process subsequently asks for more private memory via malloc, it can only possibly get as much as the distance from the original static area to the shared memory block's position in the process's address space. So I'm thinking that the EC2 environment is giving you some lowball address for the shared memory block that's constraining the process's private memory space to just a few hundred meg, even though in a 64-bit build there's room for umpteen gigabytes. Possibly it's worth filing a bug with Amazon about how they should pick a more sensible address ... but first you should confirm that theory by looking at the process memory map (should be visible in /proc someplace). It may also be that the problem is not process-address-space related but reflects some inefficiency in EC2's overall use of RAM, possibly exacerbated by PG's request for a large shared memory block. But you'd need to find an EC2 expert to investigate that idea. regards, tom lane