Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jIHAJ-00051P-Qw for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Mar 2020 19:30:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jIH9K-0006yi-LA for pgsql-hackers@arkaria.postgresql.org; Sat, 28 Mar 2020 19:29:42 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jIH9K-0006yb-7V for pgsql-hackers@lists.postgresql.org; Sat, 28 Mar 2020 19:29:42 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jIH9D-00034J-Rn for pgsql-hackers@postgresql.org; Sat, 28 Mar 2020 19:29:41 +0000 Received: by mail-pf1-x434.google.com with SMTP id k15so1240624pfh.6 for ; Sat, 28 Mar 2020 12:29:35 -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=ezRsBu8XAZArjIJNUVUNchAUvTjDDiDPq6Oq8f/91vk=; b=EmvxkeRx+gHN/NHtkbpNewmnW93eOSCUzuPbrplVjLU/WMKwp+QReJhcVC8JZajOCE TlmhQu4Dg28pPX4JZX/wh3HCU3HA6js0jLM8Ql67Vic2L/5kKo4eVdHmXyrn9r0SCFE6 lLDw9KKl1juGZmEDjSEECYmvm2Rr+8mU8M8BPcM0f8cYKHS2heruPyyCBhQ0pIVu543B XQPkvsoqTnzxMMkIuPLnUvokPSvZyqvVwrAKVrrBZYlQ//vYaQLxaPPLDaiSEiWQqeGv X59DBdK6qD3q3m4FxfKK5K0vAkhfUofOJrHd+l+5WE0Fenp/O5NVtYGDbCx1s6DGMQMj 9fAA== 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=ezRsBu8XAZArjIJNUVUNchAUvTjDDiDPq6Oq8f/91vk=; b=Xfk9X+EkBUMWe1dZCtd5rCbZi2ee9+vKC0c3bYxLTKT3BEOOqYeIUA4h/0MQjWRECv f8S4TMO9zm4QSbFxGyacGvbgCTC/tbR2oILGLc+cVBuo9UoA+8BfZezZVgf3bo2oUKVc YXOJTmtPlr0CJPf9BkB2GNp6F/FoWo0EXlEbMU2fncAftv0BJ8KxRW/IWYNX50cA8xbW nAaAGEEMHX/0F3Qdck+Pwc4ITWN7mBLuFRXbDdcgdcwQv51i0niJZ4xMf7YQSGk8D9qQ Y8WGoU7SQnY/9ZCAe6s49ef5It3Lw8EjNWliWxE1loITp/zdLhxSUOCKYSkjzjEh+rCt NBbg== X-Gm-Message-State: AGi0PuarBL9Hbjpdj+5KKgO7+1AtJD4sriEQP4SGLhDUxkfx34mPfDJp qiLoKplkv3YftVr7V/inF57rEA== X-Google-Smtp-Source: APiQypLmWdIb7+zlno9WkKt784LB2uDgH13XQ9ABE9dz1g5N9zLWntxK3WhROkvfHsV4RCkfazwx1Q== X-Received: by 2002:a63:e909:: with SMTP id i9mr941146pgh.370.1585423773004; Sat, 28 Mar 2020 12:29:33 -0700 (PDT) Received: from jdavis ([2600:1010:b00f:fd26:5437:35a6:6ca7:1d5b]) by smtp.gmail.com with ESMTPSA id o15sm1658505pgj.60.2020.03.28.12.29.31 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 28 Mar 2020 12:29:32 -0700 (PDT) Message-ID: <1dceb76c04e3b95268036f797f3dde7f8480a448.camel@j-davis.com> Subject: Re: Memory-Bounded Hash Aggregation From: Jeff Davis To: Tomas Vondra , Richard Guo Cc: Justin Pryzby , Andres Freund , Melanie Plageman , Heikki Linnakangas , Taylor Vesely , Adam Lee , Melanie Plageman , PostgreSQL-development Date: Sat, 28 Mar 2020 12:29:29 -0700 In-Reply-To: <20200327013108.tiskardwkqr5otg6@development> References: <9759ab2d0c2c28a175e11efe1788d37dc7e1b768.camel@j-davis.com> <20200222180020.ej5gvfcaf2semgji@alap3.anarazel.de> <5c371df7cee903e8cd4c685f90c6c72086d3a2dc.camel@j-davis.com> <20200224232928.45bcjmdxgnobijgi@alap3.anarazel.de> <6e7c269b9a84ff75fefcad8ab2d4758f03581e98.camel@j-davis.com> <20200312210146.GG29065@telsasoft.com> <2688fb94f3d0e571768bf851b7fde0eae780e898.camel@j-davis.com> <20200327013108.tiskardwkqr5otg6@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 Fri, 2020-03-27 at 02:31 +0100, Tomas Vondra wrote: > On Thu, Mar 26, 2020 at 05:56:56PM +0800, Richard Guo wrote: > > If nbatches is some number between 1.0 and 2.0, we would have a > > negative > > depth. As a result, we may have a negative cost for hash > > aggregation > > plan node, as described in [1]. > > numGroups / ngroups_limit ); > > and we should probably do > > nbatches = ceil(nbatches); > Thank you both. I also protected against nbatches == 0 (shouldn't happen), and against num_partitions <= 1. That allowed me to remove the conditional and simplify a bit. Regards, Jeff Davis