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 1jrBj9-000268-Ku for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2020 02:46:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jrBj8-0002eX-IO for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2020 02:46:58 +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 1jrBj8-0002eL-7g for pgsql-hackers@lists.postgresql.org; Fri, 03 Jul 2020 02:46:58 +0000 Received: from mail-il1-x131.google.com ([2607:f8b0:4864:20::131]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jrBj5-0000oh-9R for pgsql-hackers@postgresql.org; Fri, 03 Jul 2020 02:46:57 +0000 Received: by mail-il1-x131.google.com with SMTP id k6so26029544ili.6 for ; Thu, 02 Jul 2020 19:46:54 -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=yfMT0ONhEKFlizvpycs6gRXSKN52R+DpxSVPkQVPnXE=; b=zbfFJvTWWae0GRun/ZyFcmOryjWa4lfHnp6reBX9q1KtLGsS7/lK0n0K6cdncbz4qr BeLCTK0kktzqyrb9y68YON/trz8DNtvRxZSvHDwFRBMZnovjXRmw2yFUMKQoXzaFdef4 eJGN2bIIgc0TT01d3JKPx2/dMvDoTyJt1csqbiQju8+/IUbZLJ1QwU3Zj+fbvbpulrvR wpmJ4e/yEwWp+tUMYGZtfYsANDuK/UPq1WNQIVCco3QPZq6eOnDSM/Y2HmgGjZYIuDVC hk8EE2ixK3BpCeJWcw3SLZ0mpCvcnTc+WsGyfQHqRXdoUhy4EEEpaxqVmWCmdpmC4hJq KtBg== 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=yfMT0ONhEKFlizvpycs6gRXSKN52R+DpxSVPkQVPnXE=; b=NYJ8Qa/ExlzGwHW1g/PvoE+pzuucOJVRtdRG75tx4H69DzYb5YvSkdMFSuUqzhhOBl geCmi0HwP3UtdOQfFZZstdbddgSMN8fnIltkHG34JzUoaNVHo9+lkjvDs3G41UuhTZtJ v84Q4dRTxj4bc3pn9Cq6LejVl42xjXw3twgYi96ehiG/vEfCI0aLT0Mnms8PREWXQg3T z5daoVocP+QppAHl/4sEcuUGeM8GRiI9hpwpx8Aczp6csDgJHcYO1AhIzI5apoHB0EJF DmYI4EqDxg9UwMVmGaKJjXMeB0Netuch3gDRTHxed7EKdAwNjAlJoJe/rxAljHcsPC10 D3Tg== X-Gm-Message-State: AOAM5317K0WfrCZ9yQVsqiOVcFpq/BpvaC47mEoDnz7zzqJn5iNXuR6f F7/1sm9Xv05XVHpsXiysReD12w== X-Google-Smtp-Source: ABdhPJyKHPi9vi5Y9dr+EiPC5ZAU9zgj67yI2HzsH/dq5lKNqwPAkT/AT51iuHLaMChHx1SZW/MyHw== X-Received: by 2002:a92:4184:: with SMTP id o126mr14494248ila.278.1593744412825; Thu, 02 Jul 2020 19:46:52 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id c29sm3411705ilg.53.2020.07.02.19.46.51 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Jul 2020 19:46:52 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 980F98001A0; Thu, 2 Jul 2020 21:46:49 -0500 (CDT) Date: Thu, 2 Jul 2020 21:46:49 -0500 From: Justin Pryzby To: Peter Geoghegan Cc: Tomas Vondra , Bruce Momjian , Robert Haas , Andres Freund , David Rowley , Jeff Davis , Melanie Plageman , pgsql-hackers@postgresql.org Subject: Re: Default setting for enable_hashagg_disk (hash_mem) Message-ID: <20200703024649.GJ4107@telsasoft.com> References: <20200626230020.GD3337@momjian.us> <20200626235850.gvl3lpfyeobu4evi@development> <20200627104141.gq7d3hm2tvoqgjjs@development> <20200629150655.ethstxkf3bkqoown@development> <20200629212229.n3afgzq6xpxrr4cu@development> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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, Jul 02, 2020 at 07:05:48PM -0700, Peter Geoghegan wrote: > On Mon, Jun 29, 2020 at 2:46 PM Peter Geoghegan wrote: > > On Mon, Jun 29, 2020 at 2:22 PM Tomas Vondra wrote: > > > I agree with this, and I'm mostly OK with having hash_mem. In fact, from > > > the proposals in this thread I like it the most - as long as it's used > > > both during planning and execution. It's a pretty clear solution. > > > > Great. > > > > It's not trivial to write the patch, since there are a few tricky > > cases. For example, maybe there is some subtlety in nodeAgg.c with > > AGG_MIXED cases. > > Attached is an attempt at this. I have not been particularly thorough, Thanks for putting it together, I agree that hash_mem seems to be an obvious "escape hatch" that generalizes existing GUCs and independently useful. > anything else). I still think that the new GUC should work as a > multiplier of work_mem, or something else along those lines, though > for now it's just an independent work_mem used for hashing. I bring it > up again because I'm concerned about users that upgrade to Postgres 13 > incautiously, and find that hashing uses *less* memory than before. > Many users probably get away with setting work_mem quite high across > the board. At the very least, hash_mem should be ignored when it's set > to below work_mem (which isn't what the patch does). I feel it should same as work_mem, as it's written, and not a multiplier. And actually I don't think a lower value should be ignored: "mechanism not policy". Do we refuse atypical values of maintenance_work_mem < work_mem ? I assumed that hash_mem would default to -1, which would mean "fall back to work_mem". We'd then advise users to increase it if they have an issue in v13 with performance of hashes spilled to disk. (And maybe in other cases, too.) I read the argument that hash tables are a better use of RAM than sort. However it seems like setting the default to greater than work_mem is a separate change than providing the mechanism allowing user to do so. I guess the change in default is intended to mitigate the worst possible behavior change someone might experience in v13 hashing, and might be expected to improve "out of the box" performance. I'm not opposed to it, but it's not an essential part of the patch. In nodeHash.c, you missed an underscore: + * Target in-memory hashtable size is hashmem kilobytes. -- Justin