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 1jEosy-0007rp-F0 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2020 06:42:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jEosx-0007gs-81 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2020 06:42:31 +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 1jEosw-0007gk-V0 for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2020 06:42:30 +0000 Received: from mail-qk1-x741.google.com ([2607:f8b0:4864:20::741]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jEost-0004LP-3w for pgsql-hackers@postgresql.org; Thu, 19 Mar 2020 06:42:30 +0000 Received: by mail-qk1-x741.google.com with SMTP id e11so1550241qkg.9 for ; Wed, 18 Mar 2020 23:42:26 -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=WRBt01I4Zsc8gyiDmie62n94bFeULuhFdtygN7Q1w4s=; b=NVFMkolzNnfyj1qux5udZHQs4n/3YWUrgkUOxXjbSnYfzMNo+v3abIQMppN/8jYz8m W0EYHmxRIFGwdR1QGAfgLe2cKdi2xd4+ifZO5wMZgOIk6bHhxV71z4sdFtpV8flCjeDs 7PziWZiwnWxQb60VwxUeEC6wTN9l4uPQEmIvYWPzY+QR0+GxBasz8ko7MBc2M1/o839W eS8imR+r296gOsptCx/LKg/KdOUTh6gKOpQfd9UPTlavZj7hScgvdkFJqybEh7vVRfrv Zp8SK1ZjzZgFXq3go4A2BDQNwiKe5NXD7Spp0VnRa+YpJeIR0cvtRVLxWdCbDBz4uHNP z5jw== 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=WRBt01I4Zsc8gyiDmie62n94bFeULuhFdtygN7Q1w4s=; b=oBTYQFwyo/4cKIpQqHEIrbtvOYVjcr6jRfezMRuNCZomvV0/VKkBtfcdSU0rKdL+kL IAPXZ+gjjNC9hpgy4VJPPuBGXBF4kL1B0jlJZ394afoH2IZNkmYQEhMT0zy5ReAxnPaZ H2z8+gQzHvrCBnA84Q83H7mEA4mwa9d5XaS0KOqbs06VLGPwLSSGi5FnfOaaTWZaH3Eo rnzhIdBRVPc+PRP3plHmCF7H4JkiB0pMyw/oW9aezRKStxPzRb9pRppuWjF9hiD5NqdP bCQGW+qrbkM0BDwU1PpBk5ze/y2ntFXq+y8e4KZfcYQvkm2ePuK+rblsiKgeD4DCelNx tF7A== X-Gm-Message-State: ANhLgQ2vPUgwqeqs76SBXIe/G6bgu8jvHyv80W5FVVBgFdXtbCsjDI8f Btq/SUMn2VxwNNMGz+FgYZQkZw== X-Google-Smtp-Source: ADFU+vt130P17MPsvyh1hIAxwqV94KTT48IuQHs2ElFJCP9Z5BeEUgKoY3l3z16QttGJREuu6L12cw== X-Received: by 2002:a05:620a:1362:: with SMTP id d2mr1607383qkl.120.1584600145438; Wed, 18 Mar 2020 23:42:25 -0700 (PDT) Received: from pryzbyj (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id g2sm943420qkb.27.2020.03.18.23.42.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Mar 2020 23:42:24 -0700 (PDT) Received: by pryzbyj (Postfix, from userid 1000) id EEBEB800C55; Thu, 19 Mar 2020 01:42:22 -0500 (CDT) Date: Thu, 19 Mar 2020 01:42:22 -0500 From: Justin Pryzby To: Jeff Davis Cc: Andres Freund , Tomas Vondra , Melanie Plageman , Heikki Linnakangas , Taylor Vesely , Adam Lee , Melanie Plageman , pgsql-hackers@postgresql.org Subject: Re: Memory-Bounded Hash Aggregation Message-ID: <20200319064222.GR26184@telsasoft.com> References: <20200219191636.gvdywx32kwbix6kd@development> <20200221202212.ssb2qpmdgrnx52sj@alap3.anarazel.de> <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> 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 Sun, Mar 15, 2020 at 04:05:37PM -0700, Jeff Davis wrote: > > + if (from_tape) > > + partition_mem += HASHAGG_READ_BUFFER_SIZE; > > + partition_mem = npartitions * HASHAGG_WRITE_BUFFER_SIZE; > > > > => That looks wrong ; should say += ? > > Good catch! Fixed. > +++ b/src/backend/executor/nodeAgg.c > @@ -2518,9 +3499,36 @@ ExecInitAgg(Agg *node, EState *estate, int eflags) > */ > if (use_hashing) > { > + Plan *outerplan = outerPlan(node); > + uint64 totalGroups = 0; > + for (i = 0; i < aggstate->num_hashes; i++) > + totalGroups = aggstate->perhash[i].aggnode->numGroups; > + > + hash_agg_set_limits(aggstate->hashentrysize, totalGroups, 0, I realize that I missed the train but .. that looks like another += issue? Also, Andres was educating me about the range of behavior of "long" type, and I see now while rebasing that you did the same thing. https://www.postgresql.org/message-id/20200306175859.d56ohskarwldyrrw%40alap3.anarazel.de -- Justin