Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0WPZ-0000tr-5V for pgsql-performance@arkaria.postgresql.org; Thu, 04 Jun 2015 14:46:25 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z0WPY-0001qG-E9 for pgsql-performance@arkaria.postgresql.org; Thu, 04 Jun 2015 14:46:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1Z0WMd-0000CD-Fi for pgsql-performance@postgresql.org; Thu, 04 Jun 2015 14:43:23 +0000 Received: from mail-wi0-f178.google.com ([209.85.212.178]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z0WMZ-0001Dq-GP for pgsql-performance@postgresql.org; Thu, 04 Jun 2015 14:43:22 +0000 Received: by wifw1 with SMTP id w1so61159027wif.0 for ; Thu, 04 Jun 2015 07:43:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=bdYnJDlFvA6Znwtx+vvMhTo33aMWO0gl53y8w1OJBnA=; b=CVJRRiuRvhx6M4JJvoigGx2vSVrjgCal/7f/FniC0uphgzQEuINHn31WYA5Y7J046q hfQan5swSv+aq7f5oL13LMtaEQwheNRSI8zwX/1X1ookb65wXMP1WTAgae+jIB8CatEL ojgdQGOyI/UbFYAWzXTbU8S4hP/X2UzTnPJYVmSJRHzgEXqTmHHQ1osUOcKPLjJEpqch NOV3s/QTd3e2u5ltvLjZQk6NKU2qA1uUAXTndYf5GTQ9ftaCATwLvLAuEOTXsmH9Cx08 2NxtMbZxipu7/wzzUQTpummblABhaDoMfvpVPEsrmVqdhDgpyBy9PCNzjpu7yVO3x7+O GpjQ== X-Gm-Message-State: ALoCoQmaWLJ7boV5LW5ccDhYrkFYx6JKp628oX3GK+yD+kFgtgs13ipsct1W4p3QjF/iZvHKzWzlHSYzIp3Yo2cSKK6oGKPshvvBR2UK81hcYHVOFYWW63CFEQnCBjIVyCN8CwHQTQRcYeA0KjrOUIwWEfA5KLbW1LwrXrvisoESjxywBU9uCwOA6wnbUT/zVImDcMikpZCY4eB1fWFjYWksNBBuSNoOvg== X-Received: by 10.180.20.12 with SMTP id j12mr51653954wie.4.1433428997449; Thu, 04 Jun 2015 07:43:17 -0700 (PDT) Received: from [10.137.2.12] (ip-78-45-136-74.net.upcbroadband.cz. [78.45.136.74]) by mx.google.com with ESMTPSA id hm8sm6075976wjc.28.2015.06.04.07.43.15 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Jun 2015 07:43:16 -0700 (PDT) Message-ID: <55706401.4080707@2ndquadrant.com> Date: Thu, 04 Jun 2015 16:43:13 +0200 From: Tomas Vondra User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Scott Marlowe , "Joshua D. Drake" CC: "pgsql-performance@postgresql.org" Subject: Re: How to reduce writing on disk ? (90 gb on pgsql_tmp) References: <1433334092106-5852321.post@n5.nabble.com> <1433337082772-5852328.post@n5.nabble.com> <556F0649.9000402@2ndquadrant.com> <9DED5F42-2C51-4CDE-A179-56A8A9370338@playrion.com> <556F15AD.4040801@2ndquadrant.com> <556F547D.5040206@2ndquadrant.com> <556F7CAA.2080003@2ndquadrant.com> <556F7FD8.5070802@commandprompt.com> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 06/04/15 02:58, Scott Marlowe wrote: > On Wed, Jun 3, 2015 at 6:53 PM, Scott Marlowe wrote: >> On Wed, Jun 3, 2015 at 4:29 PM, Joshua D. Drake wrote: >>> >>> On 06/03/2015 03:16 PM, Tomas Vondra wrote: >>> >>>> Cache is not free memory - it's there for a purpose and usually >>>> plays a significant role in performance. Sure, it may be freed >>>> and used for other purposes, but that has consequences - e.g. >>>> it impacts performance of other queries etc. You generally >>>> don't want to do that onproduction. >>> >>> >>> Exactly. If your cache is reduced your performance is reduced >>> because less things are in cache. It is not free memory. Also the >>> command "free" is not useful in this scenario. It is almost >>> alwaysbetter to use sar so you can see where the data points are >>> thatfree is using. >> >> But if that WAS happening he wouldn't still HAVE 60G of cache! >> That's my whole point. He's NOT running out of memory. He's not >> even having to dump cache right now. No one claimed he's running out of memory ... What I claimed is that considering page cache equal to free memory is not really appropriate, because it is used for caching data, which plays a significant role. Regarding the "free" output, we have no clue when the "free" command was executed. I might have been executed while the query was running, right after it failed or long after that. That has significant impact on interpretation of the output. Also, we have no clue what happens on the machine, so it's possible there are other queries competing for the page cache, quickly filling reusing free memory (used for large query moments ago) for page cache. And finally, we have no clue what plan the query is using, so we don't know how much memory it's using before it starts spilling to disk. For example it might easily be a single sort node, taking only 384MB (the work_mem) of RAM before it starts spilling to disk. > Further if he started using a few gig here for this one it wouldn't > have a big impact on cache (60G-1G etc) but might make it much > faster, as spilling to disk is a lot less intrusive when you've got a > bigger chunk of ram to work in. OTOH doing something like setting > work_mem to 60G would likely be fatal. It'd certainly be fatal, because this query is spilling >95G to disk, and keeping that in memory would easily require 2-3x more space. > > But he's not down to 3GB of memory by any kind of imagination. Any > working machine will slowly, certainly fill its caches since it's > not using the memory for anything else. That's normal. As long as > you're not blowing out the cache you're fine. Once again, what about the 15GB shared buffers? Not that it'd change anything, really. -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services -- Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-performance