Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id AC61663350E for ; Wed, 4 Mar 2009 17:49:39 -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 24271-08 for ; Wed, 4 Mar 2009 17:49:32 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-gx0-f176.google.com (mail-gx0-f176.google.com [209.85.217.176]) by mail.postgresql.org (Postfix) with ESMTP id 9AA4E6326B5 for ; Wed, 4 Mar 2009 17:49:31 -0400 (AST) Received: by gxk24 with SMTP id 24so8117167gxk.19 for ; Wed, 04 Mar 2009 13:49:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=/q4yabmb7Q2OJUKgl7JnuIVABbK8Oo4FYmyJ1KAczFM=; b=MliutTtRY+hQ155gYMlFKsPv4RLUBGoROIcZqtTOG9SGD9VBGogXTNL48urUmzsv+a +9TGTCP1DoQ+fN4odVC3FS8gOfVC3M0nLgZ7Y30KSDWU7vNnCE5Ar0OlSbyh9Dns+Yw/ +rJ3aTtFFVBYHpFkgCsxlrPgMttcimEbe5Zt4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=CpVcJ9reUuqPyqKBsq+92zmVbXGZkNh7VR9HjumXz8yLunZVVSyr7CZwaMIslZFQNt YQZJjW9MtA01EqqzkC9EQ69NYuE/MzeIVkn2DXW728dCJOPo5cwBqfUXWsQOEsUVX/CH 1CJ5R+1Kon5B85/V0YudtAh40QM3L3WVJJXP4= MIME-Version: 1.0 Received: by 10.151.150.13 with SMTP id c13mr911845ybo.63.1236203369695; Wed, 04 Mar 2009 13:49:29 -0800 (PST) In-Reply-To: References: <13904207.99291236170787203.JavaMail.root@mail.4linux.com.br> Date: Wed, 4 Mar 2009 14:49:29 -0700 Message-ID: Subject: Re: work_mem in high transaction rate database From: Scott Marlowe To: Scott Carey Cc: Flavio Henrique Araque Gurgel , pgsql-performance Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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: 200903/45 X-Sequence-Number: 32967 On Wed, Mar 4, 2009 at 11:18 AM, Scott Carey wrot= e: > You may have decreased performance in your batch jobs with the lower > work_mem setting. That would be why I recommended benchmarking queries that need more memory and setting work_mem for those queries alone. > Additionally, the fact that you haven=92t had swap storm issues so far me= ans > that although there is certain risk of an issue, its probably a lot lower > than what has been talked about here so far. No, it means you and the OP are guessing at what's a good number without any actual proof of it. Guessing it not a particularly good method for setting work_mem, especially on a server with 2000+ connections. > Without a change in client behavior (new queries or large change in data)= a > change in load alone is very unlikely to cause a problem. That is demonstrably incorrect. If the average number of live queries out of the 2000 connections is currently 10, and an increase in load makes it 500, there is a very REAL chance of running the server out of memory. >=A0So take your time > to do it right. I believe I made mention of benchmarking queries above and in my first post. But doing it right does NOT mean setting work_mem to 2G then whittling it down as your server crashes under load. > =A0I disagree with the knee-jerk =93change it now!=94 response. > =A0The very fact you have gotten this far means it is not as risky as the= bare > settings indicate. Sorry, but I disagree back at you, and it's not a knee jerk reaction, it's a reaction honed from years of watching supposedly stable postgresql servers crash and burn under slashdot effect type loads. > Definitely plan on improving and testing out work_mem variants soon, but = a > hasty change to a small value might cause your batch jobs to take much > longer =97 what is your risk if they take too long or don=92t complete in= time? > =A0That risk is yours to assess =97 if its not much of a risk, then by al= l means > lower work_mem soon. =A0But if it is business critical for those batch jo= bs to > complete within some time frame, be careful. Sorry, but that's backwards. Unless the batch jobs are the only important thing on this server, running it with work_mem=3D2G is asking for trouble under any real kind of load. It's sacrificing stability for some unknown and quite probably minimal performance improvement. It seems a lot of your post is based on either hoping for the best, or assuming access patterns won't change much over time. Do you test at higher and higher parallel loads until failure occurs and then figure out how to limit that type of failure? I do, because I can't afford to have my db servers crash and burn midday under peak load. And you never know when some app is gonna start suddenly spewing things like unconstrained joins due to some bug, and if you've got work_mem set to 1G your server IS gonna have problems.