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 1jj5de-0003BK-TO for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2020 18:39:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jj5d5-0001t8-To for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2020 18:39:15 +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 1jj5d5-0001t1-Ma for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2020 18:39:15 +0000 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jj5cx-0001TP-V6 for pgsql-hackers@postgresql.org; Wed, 10 Jun 2020 18:39:14 +0000 Received: by mail-pg1-x544.google.com with SMTP id t7so1355636pgt.3 for ; Wed, 10 Jun 2020 11:39:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=j-davis-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=DOoz4q7GWocrAX80h6kzL1QqW8R3MJ+IKKKMMQ1RcD0=; b=kh2ZRtHy//z6iVlhYcDUXPiviZl/3Mmmo4jfNUhALda2QAmPmqlZk/YpGv1Tf3yzXi f/+vWE9UPWO9RQG/m3Ur2k1uLL3uIfZIQb/WROzpCrMeXbw0Y2OX9Qw9QLf8kknKmVpq LH4zz+UAXwr51SMPd91OTFR08DlKN2+dZHsceaFrzBDCAMigBIO4VSh0v1rJmZhE6CCa SCOfvLwTAL9e2RimDDcHthOHICPOCe4EjnzZsW/RzGGNhBdjtKSuYkUhr65BDu55UvGf 9Rzuep9oRCWp+fOMC/fXstTiFhODUJRsHqbTZCy7OqRP+23BPzSuXYGGf0rkC2LZgIY/ 2Q9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=DOoz4q7GWocrAX80h6kzL1QqW8R3MJ+IKKKMMQ1RcD0=; b=tuKrrtbpsvVzc0A3Ow+3TvpP0yrKI9LI0jFNmGQLa+BT3Umvh+1kvVaQ889C4hEuUZ 6dbeEGQ8VljsaEPaLrL/buP0qL3iwQA8cfhagbpYT3EGLODWX2gTVtlw29I6ywL0dOjY oLrLz1mRQhotks2Y6nbM4ggeu6hC3HKnw1jfwPkHPx6jZON2iwXYDJXV1MztlWkWyXRJ CZVCJFYhx9GZlWLqbT33uHAVYv1bWnNqzDyMIcNE3KTquBb4bjpm7DDPS4Cj6b2/aswx Yv2UznJB6DnPC41/vZ5cAbRTL7EIDJyS+ZRCVn/bjaI+uZZT2GEKXcp5Q9R7SuBmba05 cMVg== X-Gm-Message-State: AOAM531uf+MoqhClral/4MeCrxvDg7seRplhEvTjP+Hq4QkSIBi5i4je hpCjw6ZmZ0ziUzat4PDbB6Rk3g== X-Google-Smtp-Source: ABdhPJzrOjC55kVu8F94JhKUDyLXT0BQlEV6IR+5bwLewziO7mmcuWkB3Yel0zpwWQaq9wtDRPYC9w== X-Received: by 2002:a65:6852:: with SMTP id q18mr3771262pgt.218.1591814345621; Wed, 10 Jun 2020 11:39:05 -0700 (PDT) Received: from jdavis.lan (c-73-231-146-4.hsd1.ca.comcast.net. [73.231.146.4]) by smtp.gmail.com with ESMTPSA id u61sm449799pjb.7.2020.06.10.11.39.03 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jun 2020 11:39:04 -0700 (PDT) Message-ID: <8bff2e4e8020c3caa16b61a46918d21b573eaf78.camel@j-davis.com> Subject: Re: Default setting for enable_hashagg_disk From: Jeff Davis To: Justin Pryzby , Melanie Plageman Cc: Robert Haas , Tomas Vondra , pgsql-hackers@postgresql.org Date: Wed, 10 Jun 2020 11:39:02 -0700 In-Reply-To: <20200610021544.GA14879@telsasoft.com> References: <9d9d1e1252a52ea1bad84ea40dbebfd54e672a0f.camel@j-davis.com> <20200407223900.GT2228@telsasoft.com> <20200409114855.h4hh7e2wt77p56sv@development> <6292f5a766198d5745eb8cc17ac736366056671d.camel@j-davis.com> <20200610021544.GA14879@telsasoft.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Tue, 2020-06-09 at 21:15 -0500, Justin Pryzby wrote: > The behavior of the GUC is inconsistent with the other GUCs, which is > confusing. See also Robert's comments in this thread. > https://www.postgresql.org/message-id/20200407223900.GT2228%40telsasoft.com enable_* GUCs are planner GUCs, so it would be confusing to me if they affected execution-time behavior. I think the point of confusion is that it's not enabling/disabling an entire execution node; it only "disables" HashAgg if it thinks it will spill. I agree that is a difference with the other GUCs, and could cause confusion. Stepping back, I was trying to solve two problems with these GUCs: 1. Testing the spilling of hashed grouping sets: I'm inclined to just get rid of enable_groupingsets_hash_disk and use Melanie's stats- hacking approach instead. 2. Trying to provide an escape hatch for someone who experiences a performance regression and wants something like the old behavior back. There are two aspects of the old behavior that a user could potentially want back: a. Don't choose HashAgg if it's expected to have more groups than fit into a work_mem-sized hashtable. b. If executing HashAgg, and the hash table exceeds work_mem, just keep going. The behavior in v13 master is, by default, analagous to Sort or anything else that adapts at runtime to spill. If we had spillable HashAgg the whole time, we wouldn't be worried about #2 at all. But, out of conservatism, I am trying to accommodate users who want an escape hatch, at least for a release or two until users feel more comfortable with disk-based HashAgg. Setting enable_hash_disk=false implements 2(a). This name apparently causes confusion, but it's hard to come up with a better one because the v12 behavior has nuance that's hard to express succinctly. I don't think the names you suggested quite fit, but the idea to use a more interesting GUC value might help express the behavior. Perhaps making enable_hashagg a ternary "enable_hashagg=on|off|avoid_disk"? The word "reject" is too definite for the planner, which is working with imperfect information. In master, there is no explicit way to get 2(b), but you can just set work_mem higher in a lot of cases. If enough people want 2(b), I can add it easily. Perhaps hashagg_overflow=on|off, which would control execution time behavior? Regards, Jeff Davis