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 1jMVgA-00072N-1o for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 11:49:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jMVg8-0005xu-UD for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 11:49:04 +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 1jMVg8-0005xn-KT for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2020 11:49:04 +0000 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jMVg4-0001eB-L8 for pgsql-hackers@postgresql.org; Thu, 09 Apr 2020 11:49:03 +0000 Received: by mail-wr1-x441.google.com with SMTP id g3so11607547wrx.2 for ; Thu, 09 Apr 2020 04:49:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=6WH5pOkcT0goTMZpShNiANGRPePp18Yj+V/MqnmECOs=; b=z67Khh6oTTikadVuQJ4BljREEvXnuZfxKd5Zss+yYK1Jt3CkLoq+eZ6YMKOVc1CoyW 1gOaHT9q/I0HILllen+XPqY2KEb2yRCZs0KgHaHpMSrd7X5Qiefxw00A1Tz5/9lCGgV3 FQhgY5K0C5l/zFuLOwl7dAYgEpOWe7JyG9so9GGA8SnG1TVBOXnIMxrAmQhtH9GKwFs9 kWkC2Cw2RZjs8sLUcLqiC4DsyuoTF51urm7i3O5zu64rMLhRn+q+bw1pkDjznTlilzWC r1LTAnrFMP0Ue9pbxa3fUBVDFL/idLER0kX0QtdwZIyarB+GZgLPsBNGC5cftdOJ8E8F hYRg== 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; bh=6WH5pOkcT0goTMZpShNiANGRPePp18Yj+V/MqnmECOs=; b=oiKe4eJZ9ZG3XAGH4JYgeRw0QAaV3CzIiy4V9shQ2tunyby8dXkdJ09cPFCKa6tj1R 2aiA7YZ6DwxAXeVg6/ePbsK19J8Sscric+F5oKxJLBUjHiKaueD77wkZ+pkrBFFMJKwF PUVgMl3hzn5zk6bT7hZGiWMbc+sAD+FyKHkgyWPkmKouQ+BtGkWr7rWrJJgwP/EfJXDb Qk4bTBV50+IPBgAIJj6rGLzUbwrhuwppxqyYXsGlD8pPxD8yQbBfYaaL+rQ54XZTStz3 vAg06dkJCRPYpXuDxnj1OscoGQAF+oqQl7HKHZRYvgHL6k601ZIUGHME5LWZMLSjzcx1 HPSA== X-Gm-Message-State: AGi0PuaVIuR51f9sego+R4g3RDLOP1hSpmE42LWi2LBLjg8JqKm944fa 5DMIkNS906cxWjJWcRu4EFMiiA== X-Google-Smtp-Source: APiQypLlF1uHc7Uovo7vhF4yb7pFwefecUncrWhOgcukFqD+PSmDk3nI6pld7ekx9+DkheLsJMSP8A== X-Received: by 2002:adf:f98b:: with SMTP id f11mr13687070wrr.259.1586432939180; Thu, 09 Apr 2020 04:48:59 -0700 (PDT) Received: from localhost (ip-86-49-253-141.net.upcbroadband.cz. [86.49.253.141]) by smtp.gmail.com with ESMTPSA id 132sm3291680wmc.47.2020.04.09.04.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2020 04:48:58 -0700 (PDT) Date: Thu, 9 Apr 2020 13:48:55 +0200 From: Tomas Vondra To: Justin Pryzby Cc: Jeff Davis , pgsql-hackers@postgresql.org Subject: Re: Default setting for enable_hashagg_disk Message-ID: <20200409114855.h4hh7e2wt77p56sv@development> References: <9d9d1e1252a52ea1bad84ea40dbebfd54e672a0f.camel@j-davis.com> <20200407223900.GT2228@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20200407223900.GT2228@telsasoft.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. >template1=# explain (analyze, costs off, summary off) SELECT a, COUNT(1) FROM generate_series(1,999999) a GROUP BY 1 ; > HashAggregate (actual time=1370.945..2877.250 rows=999999 loops=1) > Group Key: a > Peak Memory Usage: 5017 kB > Disk Usage: 22992 kB > HashAgg Batches: 84 > -> Function Scan on generate_series a (actual time=314.507..741.517 rows=999999 loops=1) > >A previous version of the docs said this, which I thought was confusing, and you removed it. >But I guess this is the behavior it was trying to .. explain. > >+ enable_hashagg_disk (boolean) >+ ... This only affects the planner choice; >+ execution time may still require using disk-based hash >+ aggregation. The default is on. > >I suggest that should be reworded and then re-introduced, unless there's some >further behavior change allowing the previous behavior of >might-exceed-work-mem. > Yeah, it would be good to mention this is a best-effort setting. >"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? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services