Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Z0GxR-0007f2-Ds for pgsql-performance@arkaria.postgresql.org; Wed, 03 Jun 2015 22:16:21 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1Z0GxQ-0007OV-K7 for pgsql-performance@arkaria.postgresql.org; Wed, 03 Jun 2015 22:16:20 +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 1Z0GxP-0007OO-Hu for pgsql-performance@postgresql.org; Wed, 03 Jun 2015 22:16:19 +0000 Received: from mail-wg0-f48.google.com ([74.125.82.48]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1Z0GxL-0007lu-PO for pgsql-performance@postgresql.org; Wed, 03 Jun 2015 22:16:18 +0000 Received: by wgbgq6 with SMTP id gq6so20214152wgb.3 for ; Wed, 03 Jun 2015 15:16:14 -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=em7zUPjhc1kXkqT1aYFONdsz1+t+0qp5b6s/s9OEjQY=; b=L7VjU9bf5dAyMWFw839DKmrKIrnrx0T1lVdTy9JKPmmxn3FD3uJpsMJP9RPsn7HyyA d3PzdnaiovAODs4rgczIoLSdl8OaPejy4+2+c2t5WWft+A6nuKv685VjRMdK4TYgcRXA KmqfSd07c8IzR6lgak4NXKiWDwBcEg2od75jOGNgMvoWSd6H7W62YHilbX6ecUGPk7hp 2Jfr3RpzI35K008EFswWF8WJG4hosHO1TGi8cJzibYZs8fI61k//zzcsPMNsV6ySNQgS DvI6Tm3yaDmYwnOyxe7L8juVIP/JDpT2LRVx8w7zcyNanB1zUtbTReMciiUwn9OgpCur y1vg== X-Gm-Message-State: ALoCoQliBYxlj5emOHVeOPoLfehGX5/jN6MyQW0R1e39q92g7lxsjqBEH5c8DKiQpv27ccoGKQ+vH/CvaD+jzT0w+o2ubZsCxmMTBLg2PDDW576KXD37BPmphOmb94iQfDauL5fixP2ZxUT760X1mhYEgqpF8OhSnE+D7NnwGqTMEIXqmfCSP9ykq6Rn5QWAbaJ4K8P9HiOewhkDQjtlWdQuyCWM7Xz+2w== X-Received: by 10.194.60.164 with SMTP id i4mr65691933wjr.133.1433369774082; Wed, 03 Jun 2015 15:16:14 -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 k2sm3531116wif.3.2015.06.03.15.16.12 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Jun 2015 15:16:13 -0700 (PDT) Message-ID: <556F7CAA.2080003@2ndquadrant.com> Date: Thu, 04 Jun 2015 00:16:10 +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 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> 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/03/15 23:18, Scott Marlowe wrote: > On Wed, Jun 3, 2015 at 1:24 PM, Tomas Vondra > wrote: >> >> On 06/03/15 17:09, Scott Marlowe wrote: >>> >>> On Wed, Jun 3, 2015 at 8:56 AM, Tomas Vondra >>> >> Well, except that 15GB of that is shared_buffers, and I wouldn't call that >> 'free'. Also, I don't see page cache as entirely free - you probably want at >> least some caching at this level. >> >> In any case, even if all 64GB were free, this would not be enough for the >> query that needs >95GB for temp files. > > You can argue all you want, but this machine has plenty of free memory > right now, and unless the OP goes crazy and cranks up work_mem to some > much higher level it'll stay that way, which is good. There's far far > more than 300MB free here. At the drop of a hat there can be ~60G > freed up as needed, either for shared_buffers or work_mem or other > things to happen. Cache doesn't count as "used" in terms of real > memory pressure. IE you're not gonna start getting swapping becase you > need more memory, it'll just come from the cache. Please, could you explain how you free 60GB 'as need' when 15GB of that is actually used for shared buffers? Also, we don't know how much of that cache is 'dirty' which makes it more difficult to free. What is more important, though, is the amount of memory. OP reported the query writes ~95GB of temp files (and dies because of full disk, so there may be more). The on-disk format is usually more compact than the in-memory representation - for example on-disk sort often needs 3x less space than in-memory qsort. So we can assume the query needs >95GB of data. Can you explain how that's going to fit into the 64GB RAM? > Cache is free memory. If you think of it any other way when you're > looking at memory usage and pressure on theings like swap you're > gonna make some bad decisions. 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 on production. -- 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