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 1jrN7A-0000P6-5K for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2020 14:56:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jrN79-000445-3n for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2020 14:56:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jrN78-00041Q-Nq for pgsql-hackers@lists.postgresql.org; Fri, 03 Jul 2020 14:56:30 +0000 Received: from mail-io1-xd2d.google.com ([2607:f8b0:4864:20::d2d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jrN71-0003T4-KY for pgsql-hackers@postgresql.org; Fri, 03 Jul 2020 14:56:29 +0000 Received: by mail-io1-xd2d.google.com with SMTP id a12so32745421ion.13 for ; Fri, 03 Jul 2020 07:56:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kPsWxWKLANWh9huugB3dk9PFPwTvN4LOq5iRH3xVIl0=; b=K2ahpTN4iclwaiPn3ZWs6J/fj8LOnDCN//YxIDHgYWywT/DlNr6ex5wg2dFFhp3oCx k2NEbaDvHtXiVbmJ4yr7FRIQklmU0PZ3SY4/231URs3YIzGdHO4F5LS77oJTWbjK2tlp zPMm1NM6N3A6R1n053giQ9w60a1tiR5MIPX4DEe9bG8B2FJe0auzX/SABI4eXa16ZncN 60dQxTFLd8MCKCDM14jOxB4L8lO8J5pp6y/7aKkFIaJBnEr7E/dIz8LUC2IalQsOfbB8 ytfOCgLeXu4Y1m8FzNgwc0SYLdRLPgqUKEF+RyDKSFbgXz/RbsuYD/+yeIefQao6a47d 2VoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=kPsWxWKLANWh9huugB3dk9PFPwTvN4LOq5iRH3xVIl0=; b=Ed4R+yi/QxyIBMA35ldgDpSJRUm928IVpGq6m7KC1XZ3FGjG6HOlwy4bl+52Ut0C/Q PWVmYaGhHC2unZkaCfd5nwYBYW2cLS48MPbQ7aEfR5dn6tj565fU9K5xU1CNSr44Zxv5 k2O7W38hjispSgZ2YleSeM+kJbuMuu1n4NXwRipqVIuboIAzflDbg6Niv86SczP1ybW8 xtHncf8Wvzm2YNV3rDPBn1Z/v6B4CvXmTayqV3n3yeH7lNdYSF8t6bMzN1FsELZgOhuM z/KQvWmqdWv0Wzi1R8eKh4Dc3W7rHd6i++YNS4T8HOiQsstfUz92aIlPCbij2QpHQBVS iGgQ== X-Gm-Message-State: AOAM530f9SSYKO2K9vo3bOodN8DUyyHQYpQDHZSLyEaBHYVo1bRZL1et FsnVPyhZnlUkGnzUPm0TZed+/w== X-Google-Smtp-Source: ABdhPJx4UVtVwxUS8EGQ4PYV2KwwOWd45Tu1IlaMaJ4ujig4s6KfaMEc7nRCpG6No4oEfgB0q/QRZA== X-Received: by 2002:a02:b714:: with SMTP id g20mr31883712jam.117.1593788182497; Fri, 03 Jul 2020 07:56:22 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id j17sm6580305ilq.7.2020.07.03.07.56.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jul 2020 07:56:21 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 5F46F800585; Fri, 3 Jul 2020 09:56:20 -0500 (CDT) Date: Fri, 3 Jul 2020 09:56:20 -0500 From: Justin Pryzby To: Bruce Momjian Cc: Peter Geoghegan , Tomas Vondra , Robert Haas , Andres Freund , David Rowley , Jeff Davis , Melanie Plageman , PostgreSQL Hackers Subject: Re: Default setting for enable_hashagg_disk (hash_mem) Message-ID: <20200703145620.GK4107@telsasoft.com> References: <20200629150655.ethstxkf3bkqoown@development> <20200629212229.n3afgzq6xpxrr4cu@development> <20200703024649.GJ4107@telsasoft.com> <20200703025834.GC26235@momjian.us> <20200703030001.GD26235@momjian.us> <20200703140808.GE26235@momjian.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200703140808.GE26235@momjian.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Fri, Jul 03, 2020 at 10:08:08AM -0400, Bruce Momjian wrote: > On Thu, Jul 2, 2020 at 08:35:40PM -0700, Peter Geoghegan wrote: > > But the problem isn't really the hashaggs-that-spill patch itself. > > Rather, the problem is the way that work_mem is supposed to behave in > > general, and the impact that that has on hash aggregate now that it > > has finally been brought into line with every other kind of executor > > node. There just isn't much reason to think that we should give the > > same amount of memory to a groupagg + sort as a hash aggregate. The > > patch more or less broke an existing behavior that is itself > > officially broken. That is, the problem that we're trying to fix here > > is only a problem to the extent that the previous scheme isn't really > > operating as intended (because grouping estimates are inherently very > > hard). A revert doesn't seem like it helps anyone. > > > > I accept that the idea of inventing hash_mem to fix this problem now > > is unorthodox. In a certain sense it solves problems beyond the > > problems that we're theoretically obligated to solve now. But any > > "more conservative" approach that I can think of seems like a big > > mess. > > Well, the bottom line is that we are designing features during beta. > People are supposed to be testing PG 13 behavior during beta, including > optimizer behavior. We don't even have a user report yet of a > regression compared to PG 12, or one that can't be fixed by increasing > work_mem. > > If we add a new behavior to PG 13, we then have the pre-PG 13 behavior, > the pre-patch behavior, and the post-patch behavior. How are people > supposed to test all of that? Add to that that some don't even feel we > need a new behavior, which is delaying any patch from being applied. If we default hash_mem=-1, the post-patch behavior by default would be same as the pre-patch behavior. Actually, another reason it should be -1 is simply to reduce the minimum, essential number of GUCs everyone has to change or review on a new installs of a dedicated or nontrivial instance. shared_buffers, max_wal_size, checkpoint_timeout, eff_cache_size, work_mem. I don't think anybody said it before, but now it occurs to me that one advantage of making hash_mem a multiplier (I'm thinking of hash_mem_scale_factor) rather than an absolute is that one wouldn't need to remember to increase hash_mem every time they increase work_mem. Otherwise, this is kind of a foot-gun: hash_mem would default to 16MB, and people experiencing poor performance would increase work_mem to 256MB like they've been doing for decades, and see no effect. Or someone would increase work_mem from 4MB to 256MB, which exceeds hash_mem default of 16MB, so then (if Peter has his way) hash_mem is ignored. Due to these behaviors, I'll retract my previous preference: | "I feel it should same as work_mem, as it's written, and not a multiplier." I think the better ideas are: - hash_mem=-1 - hash_mem_scale_factor=1 ? Maybe as a separate patch we'd set default hash_mem_scale_factor=4, possibly only in master not and v13. -- Justin