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 1jMauT-0001Fp-K0 for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 17:24: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 1jMauS-0007km-He for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 17:24:12 +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 1jMauS-0007ke-AX for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2020 17:24:12 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jMauQ-0006tB-BN for pgsql-hackers@postgresql.org; Thu, 09 Apr 2020 17:24:11 +0000 Received: by mail-qt1-x842.google.com with SMTP id w24so522713qts.11 for ; Thu, 09 Apr 2020 10:24:09 -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=K0QckKf8pAWjDz1R4G0pSxrelegj1h9yMVhfJ252VD0=; b=j9LcV7stAgHuKH+qqtAT1LeKcWR7MHqxXOwEDjk9tmRKkMFnympQH95M/HlRjc0UOi qZt52ZebpmyJP6MPPNQZGVX1BJODVmzjQh3HR2SsdBJf63PQYWjFcrJ2maoCXYPJtQyL tA76h3vni8sG2idlvuJbmoU6bTiv9EDf/sqbNirRy5l0gQLDKfgcbKuAo7SI1OIbAptd VEkEU7yyvR9EAGQ2pV40fMlwjqGIY3aQxGlhR+Q2gip0AUFIJC+3NJp6w9peWb6N6gBT B6PT5m9VZnwbRqXB7YFbuHZnzfmSPVI+TXr1a8yCPsBSPtKOFiQpcyepl9EAcwBabBRM zZAg== 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=K0QckKf8pAWjDz1R4G0pSxrelegj1h9yMVhfJ252VD0=; b=HcDGC5ooWGK76ppZbiYNz1OUIsuKLMOw7MhaxgLRqk3UIrtFlI3ad+HneYBE4kSdTv hWLMzNbwidzTHQj7uUnBfjKQmX0WkLKgYnPAPBLnllkvrgjCqyp94P4Rl/31AbG/wi7r d2NFgGZDkaHzwupAvgHum8EHmRxcDDUMlzDk+AqhSPV8KEmXvVLSu1d1oXMEG3WCPH3n UcQRt8PYT4/bAHImnVdEFCOEst0HLM0ee4dPruzhO91adWtfydzPZB6JqSlaEa6iKmTM Wc1LtUlcA9VJWeNJL4jlphoUvnktE32DJha1wmdtZcHvwFqdH665tk2bkelDGflbcERA iHFA== X-Gm-Message-State: AGi0PuZejFBkowTsA8BC/npbLhZ31VHpgN6WqoVGi/rg/m1N5PdfP78z qS5EMnwlTCyXwSWQmh0fsg0+1YGW6VQ= X-Google-Smtp-Source: APiQypIhCzPoe8pu38i2WM3RE+hPe68t8HBre32WvTtwTMIvBQ1XXcl7hN+LONqyZi6ex1j7HgmDGQ== X-Received: by 2002:ac8:1bbd:: with SMTP id z58mr437286qtj.94.1586453047397; Thu, 09 Apr 2020 10:24:07 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id x24sm10174209qth.80.2020.04.09.10.24.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Apr 2020 10:24:06 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id AB5D18007F7; Thu, 9 Apr 2020 12:24:04 -0500 (CDT) Date: Thu, 9 Apr 2020 12:24:04 -0500 From: Justin Pryzby To: Tomas Vondra Cc: Jeff Davis , pgsql-hackers@postgresql.org Subject: Re: Default setting for enable_hashagg_disk Message-ID: <20200409172404.GR2228@telsasoft.com> References: <9d9d1e1252a52ea1bad84ea40dbebfd54e672a0f.camel@j-davis.com> <20200407223900.GT2228@telsasoft.com> <20200409114855.h4hh7e2wt77p56sv@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200409114855.h4hh7e2wt77p56sv@development> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Apr 09, 2020 at 01:48:55PM +0200, Tomas Vondra wrote: > On Tue, Apr 07, 2020 at 05:39:01PM -0500, Justin Pryzby wrote: > > On Tue, Apr 07, 2020 at 11:20:46AM -0700, Jeff Davis wrote: > > > The enable_hashagg_disk GUC, if set to true, chooses HashAgg based on > > > costing. If false, it only generates a HashAgg path if it thinks it will fit > > > in work_mem, similar to the old behavior (though it wlil now spill to disk if > > > the planner was wrong about it fitting in work_mem). The current default is > > > true. > > > > Are there any other GUCs that behave like that ? It's confusing to me when I > > see "Disk Usage: ... kB", despite setting it to "disable", and without the > > usual disable_cost. I realize that postgres chose the plan on the hypothesis > > that it would *not* exceed work_mem, and that spilling to disk is considered > > preferable to ignoring the setting, and that "going back" to planning phase > > isn't a possibility. > > It it really any different from our enable_* GUCs? Even if you do e.g. > enable_sort=off, we may still do a sort. Same for enable_groupagg etc. Those show that the GUC was disabled by showing disable_cost. That's what's different about this one. Also.. there's no such thing as enable_groupagg? Unless I've been missing out on something. > > "This setting determines whether the planner will elect to use a hash plan > > which it expects will exceed work_mem and spill to disk. During execution, > > hash nodes which exceed work_mem will spill to disk even if this setting is > > disabled. To avoid spilling to disk, either increase work_mem (or set > > enable_hashagg=off)." > > > > For sure the release notes should recommend re-calibrating work_mem. > > I don't follow. Why would the recalibrating be needed? Because HashAgg plans which used to run fine (because they weren't prevented from overflowing work_mem) might now run poorly after spilling to disk (because of overflowing work_mem). -- Justin