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.89) (envelope-from ) id 1hlpYh-0000Xn-Ad for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2019 07:01:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1hlpYg-0001Bk-7Y for pgsql-hackers@arkaria.postgresql.org; Fri, 12 Jul 2019 07:01:30 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlpXM-0003bb-C8 for pgsql-hackers@lists.postgresql.org; Fri, 12 Jul 2019 07:00:08 +0000 Received: from mail-lj1-x243.google.com ([2a00:1450:4864:20::243]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hlpXJ-0001cR-KI for pgsql-hackers@postgresql.org; Fri, 12 Jul 2019 07:00:06 +0000 Received: by mail-lj1-x243.google.com with SMTP id v24so8263001ljg.13 for ; Fri, 12 Jul 2019 00:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-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=rBcq5qH0KXyj1fB5sonGXj11OENRmrQjNnFrXzKM9+4=; b=RlRYDnl4HFh2VhbyHqBmif24rgMlEfG3JHRWSo6oNKYvt2I8VoeyZb6KY7zOtGezPr xb2BkzgRD0a+eL1IeSaZL+mST1MhE4GnguRJtUDSBbkoEKnhNYzqkjwqid7pEAoHCSD0 P/sCfvXAIHN1Hvwk5ad3KvvaquL9hLp0En8b/hTKSoPGp33n4c0mvmo0t2XU0dT7YhYF xjJg8Ov1Nw6BJSGv1FwKtB4A0sudZoM7r89oOnxwzFvekj/dy6MXthaHm2uGYjDYRm2C 4Y7oRsoJ2kpJdZ1OWVbp5WvqBgHgJ1WxV/tcBakwgVCa6o7Zacym94bRcBZz+oCpzGjj X5kg== 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=rBcq5qH0KXyj1fB5sonGXj11OENRmrQjNnFrXzKM9+4=; b=hh6MVnWXBgzsHBN5BE/8mriZNgUQXcWiyEe2mV+CxsuX00pQFT2joIrexNw9Gif2za puNa9kAFWvHg+SC7d3DTCfeD4hCGjttLxamyP/twseLt5/Gk9rOEu9a7tQVAl1WI3ky5 824Nz3MLjhEVJZabjW4d57qguEGJMj/Yx0Bl1AZfCfv/ZJKdmkoEU108nAuO68En4Tzv h7O7WHsEgTL4C4GHYsn1FsC2pMdy0yAMv9/UM8g4C4EqoJqWeE4OtQSD9BbkJ4irydeE rL9NwOk68YR67oqk6H2QbWG2W45XdRLnGZd0egGD7ksnk0Tr4DH+W+zYGzbX6hCS+oEn cMDA== X-Gm-Message-State: APjAAAWiQG1ipUL6V7Dfd04H2McdNvjCPjKIaVgvQZ1YNTdtPUpRIYjj oTA6rGC3e3HRvcaA522x+2nCYmFcp1Rqvg== X-Google-Smtp-Source: APXvYqxvgLwwvt7vso0/TU868aJpNEKVmftyTzh0QfZMDBkb7LwMnWbG2HGnWmeLxkVcyU1WC28hgQ== X-Received: by 2002:a2e:8802:: with SMTP id x2mr4892311ljh.200.1562914803867; Fri, 12 Jul 2019 00:00:03 -0700 (PDT) Received: from localhost ([217.8.174.100]) by smtp.gmail.com with ESMTPSA id v17sm1463743ljg.36.2019.07.12.00.00.02 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 12 Jul 2019 00:00:02 -0700 (PDT) Date: Fri, 12 Jul 2019 08:59:55 +0200 From: Tomas Vondra To: Jeff Davis Cc: pgsql-hackers@postgresql.org Subject: Re: Memory-Bounded Hash Aggregation Message-ID: <20190712065955.pm2rnk2hxa3qqawf@development> References: <507ac540ec7c20136364b5272acbcd4574aa76ef.camel@j-davis.com> <20190703001753.s5e5cme3ucjgeu6c@development> <20190711155520.zqipi23o3yybx7ym@development> <9be86fc1adc315f69b8af4b379087ab451008d8a.camel@j-davis.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <9be86fc1adc315f69b8af4b379087ab451008d8a.camel@j-davis.com> User-Agent: NeoMutt/20180716-1444-295967-dirty List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, Jul 11, 2019 at 06:06:33PM -0700, Jeff Davis wrote: >On Thu, 2019-07-11 at 17:55 +0200, Tomas Vondra wrote: >> Makes sense. I haven't thought about how the hybrid approach would be >> implemented very much, so I can't quite judge how complicated would >> it be >> to extend "approach 1" later. But if you think it's a sensible first >> step, >> I trust you. And I certainly agree we need something to compare the >> other >> approaches against. > >Is this a duplicate of your previous email? > Yes. I don't know how I managed to send it again. Sorry. >I'm slightly confused but I will use the opportunity to put out another >WIP patch. The patch could use a few rounds of cleanup and quality >work, but the funcionality is there and the performance seems >reasonable. > >I rebased on master and fixed a few bugs, and most importantly, added >tests. > >It seems to be working with grouping sets fine. It will take a little >longer to get good performance numbers, but even for group size of one, >I'm seeing HashAgg get close to Sort+Group in some cases. > Nice! That's a very nice progress! >You are right that the missed lookups appear to be costly, at least >when the data all fits in system memory. I think it's the cache misses, >because sometimes reducing work_mem improves performance. I'll try >tuning the number of buckets for the hash table and see if that helps. >If not, then the performance still seems pretty good to me. > >Of course, HashAgg can beat sort for larger group sizes, but I'll try >to gather some more data on the cross-over point. > Yes, makes sense. I think it's acceptable as long as we consider this during costing (when we know in advance we'll need this) or treat it to be emergency measure. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services