Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jorMj-0000FJ-9z for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jun 2020 16:38:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jorMB-0000xf-Oq for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jun 2020 16:37:39 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jorMB-0000xX-He for pgsql-hackers@lists.postgresql.org; Fri, 26 Jun 2020 16:37:39 +0000 Received: from momjian.us ([72.94.173.45]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jorM3-00019m-IM for pgsql-hackers@postgresql.org; Fri, 26 Jun 2020 16:37:39 +0000 Received: from bruce by momjian.us with local (Exim 4.92) (envelope-from ) id 1jorLy-0006gv-De; Fri, 26 Jun 2020 12:37:26 -0400 Date: Fri, 26 Jun 2020 12:37:26 -0400 From: Bruce Momjian To: Tomas Vondra Cc: Robert Haas , Andres Freund , David Rowley , Jeff Davis , Justin Pryzby , Melanie Plageman , "pgsql-hackers@postgresql.org" Subject: Re: Default setting for enable_hashagg_disk Message-ID: <20200626163726.GA3337@momjian.us> References: <20200624171203.GB17842@momjian.us> <20200624191900.t4sbfk236gndwoa3@alap3.anarazel.de> <20200624231810.GB13627@momjian.us> <20200624233837.GA21436@momjian.us> <20200625171756.GB12486@momjian.us> <20200625235357.udlest4k6i2uekui@development> <20200626040210.GA13963@momjian.us> <20200626144414.rftlidu34rigiulv@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200626144414.rftlidu34rigiulv@development> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Jun 26, 2020 at 04:44:14PM +0200, Tomas Vondra wrote: > On Fri, Jun 26, 2020 at 12:02:10AM -0400, Bruce Momjian wrote: > > On Fri, Jun 26, 2020 at 01:53:57AM +0200, Tomas Vondra wrote: > > > I'm not saying it's not beneficial to use different limits for different > > > nodes. Some nodes are less sensitive to the size (e.g. sorting often > > > gets faster with smaller work_mem). But I think we should instead have a > > > per-session limit, and the planner should "distribute" the memory to > > > different nodes. It's a hard problem, of course. > > > > Yeah, I am actually confused why we haven't developed a global memory > > allocation strategy and continue to use per-session work_mem. > > > > I think it's pretty hard problem, actually. One of the reasons is that Yes, it is a hard problem, because it is balancing memory for shared buffers, work_mem, and kernel buffers: https://momjian.us/main/blogs/pgblog/2018.html#December_7_2018 I think the big problem is that the work_mem value is not one value but a floating value that is different per query and session, and concurrent session activity. > the costing of a node depends on the amount of memory available to the > node, but as we're building the plan bottom-up, we have no information > about the nodes above us. So we don't know if there are operations that > will need memory, how sensitive they are, etc. > > And so far the per-node limit served us pretty well, I think. So I'm not > very confused we don't have the per-session limit yet, TBH. I was thinking more of being able to allocate a single value to be shared by all active sesions. Also, doesn't this blog entry also show that spiling to disk for ORDER BY is similarly slow compared to hash aggs? https://momjian.us/main/blogs/pgblog/2012.html#February_2_2012 -- Bruce Momjian https://momjian.us EnterpriseDB https://enterprisedb.com The usefulness of a cup is in its emptiness, Bruce Lee