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 1jMdNR-0006eP-Qw for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 20:02:17 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jMdNQ-0006MO-IY for pgsql-hackers@arkaria.postgresql.org; Thu, 09 Apr 2020 20:02:16 +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 1jMdNQ-0006MH-8m for pgsql-hackers@lists.postgresql.org; Thu, 09 Apr 2020 20:02:16 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jMdNN-0008Fq-KD for pgsql-hackers@postgresql.org; Thu, 09 Apr 2020 20:02:15 +0000 Received: by mail-pf1-x42c.google.com with SMTP id v23so16886pfm.1 for ; Thu, 09 Apr 2020 13:02:13 -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=EaH1DZzBH2Y4Iuq/MP0+W3v1pcz+K5W1HuufTQXNXkM=; b=Qh/Qfjxm5t0jIoMyPw5UMM7LbTKfdfTdRwnlk6e9FXpFjbyPS43cGt4z/jZ9+I3nv6 RxMmyf731G4AO6hfWeHqTcQfpuG7r72PuFmd6yC3FaBda/qhueFYmDFLCvX42xiSGUc9 ij17orpg2d89n/sL+9TmJiQwKNXkPQ3MGGRVBmisu3G8kN1whHMuFstNbaXRlcRc4TOD IARA4oZhpiWGU4E19d1/2H7piQ0RYPi54HnkudVOo9IMb122pJHfPJVJ6QVkMykMukey MheG/mBAPuPuoC8DI8P7cUvpjW1q9WwNzQl070q7rvhwsN09n7gtK8bIT7viVT0SGx8G WzgA== 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=EaH1DZzBH2Y4Iuq/MP0+W3v1pcz+K5W1HuufTQXNXkM=; b=SWb2w6aq1kh5zG9wFxvyyWubsznV6QiSd1GE52ZBB7imBdWIZftJRq9EMBkvfymJnL KiaSByig/OE+E5MwAIQPqbMg7uIloi7E+93Lwc6RHz5x6q2rTs8H+CuRuMJaUFNwg25p 1zJDWbNg7EIymptIB1qs984u/NmXgmCXoynsr5ZKH7LVVYEnjesRuYJZJKQcGnrhvBxW /yiAhNl6ZR5pcS2kEGxN3fr2m5aZF7QGY9OA5J84eXj740o2hJ3ypOoNTNAbODcIEYrz b8v7MEziOO3Xeygd7mGl3L2DKugLHIP/z/VS7D97igPL4NZ/RhU71OEPXmoWEXzDbiI8 OFLA== X-Gm-Message-State: AGi0Puav3Oxo9LvKvkXg+J1PxBUrQ+q71iqTHZDMXhANO4atPVgVKUHu y+OT0SJrQ3PbMJMbsMi5cnYySvZzwRI= X-Google-Smtp-Source: APiQypI+4NVnA57HN6BCw+MNDLb09sOkYHcDzgkH+eexwAr7ENd1Yn4qk1s3ydyG2PVBHJjqhwlg2Q== X-Received: by 2002:a63:5e44:: with SMTP id s65mr1173595pgb.112.1586462530013; Thu, 09 Apr 2020 13:02:10 -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 f11sm7176713pfa.149.2020.04.09.13.02.08 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 09 Apr 2020 13:02:09 -0700 (PDT) Message-ID: <6292f5a766198d5745eb8cc17ac736366056671d.camel@j-davis.com> Subject: Re: Default setting for enable_hashagg_disk From: Jeff Davis To: Robert Haas , Tomas Vondra Cc: Justin Pryzby , "pgsql-hackers@postgresql.org" Date: Thu, 09 Apr 2020 13:02:07 -0700 In-Reply-To: References: <9d9d1e1252a52ea1bad84ea40dbebfd54e672a0f.camel@j-davis.com> <20200407223900.GT2228@telsasoft.com> <20200409114855.h4hh7e2wt77p56sv@development> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 2020-04-09 at 15:26 -0400, Robert Haas wrote: > I think it's actually pretty different. All of the other enable_* > GUCs > disable an entire type of plan node, except for cases where that > would > otherwise result in planning failure. This just disables a portion of > the planning logic for a certain kind of node, without actually > disabling the whole node type. I'm not sure that's a bad idea, but it > definitely seems to be inconsistent with what we've done in the past. The patch adds two GUCs. Both are slightly weird, to be honest, but let me explain the reasoning. I am open to other suggestions. 1. enable_hashagg_disk (default true): This is essentially there just to get some of the old behavior back, to give people an escape hatch if they see bad plans while we are tweaking the costing. The old behavior was weird, so this GUC is also weird. Perhaps we can make this a compatibility GUC that we eventually drop? I don't necessarily think this GUC would make sense, say, 5 versions from now. I'm just trying to be conservative because I know that, even if the plans are faster for 90% of people, the other 10% will be unhappy and want a way to work around it. 2. enable_groupingsets_hash_disk (default false): This is about how we choose which grouping sets to hash and which to sort when generating mixed mode paths. Even before this patch, there are quite a few paths that could be generated. It tries to estimate the size of each grouping set's hash table, and then see how many it can fit in work_mem (knapsack), while also taking advantage of any path keys, etc. With Disk-based Hash Aggregation, in principle we can generate paths representing any combination of hashing and sorting for the grouping sets. But that would be overkill (and grow to a huge number of paths if we have more than a handful of grouping sets). So I think the existing planner logic for grouping sets is fine for now. We might come up with a better approach later. But that created a testing problem, because if the planner estimates correctly, no hashed grouping sets will spill, and the spilling code won't be exercised. This GUC makes the planner disregard which grouping sets' hash tables will fit, making it much easier to exercise the spilling code. Is there a better way I should be testing this code path? Regards, Jeff Davis