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 1juOqb-0002mM-SK for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Jul 2020 23:23:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1juOqa-0008Ch-EP for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Jul 2020 23:23:56 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1juOqa-0008Ca-7a for pgsql-hackers@lists.postgresql.org; Sat, 11 Jul 2020 23:23:56 +0000 Received: from mail-ej1-x644.google.com ([2a00:1450:4864:20::644]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1juOqX-0000jb-8F for pgsql-hackers@postgresql.org; Sat, 11 Jul 2020 23:23:54 +0000 Received: by mail-ej1-x644.google.com with SMTP id w16so10227099ejj.5 for ; Sat, 11 Jul 2020 16:23:52 -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; bh=izTyuzXMN64QnzTHSBDqz5MmAJ8BHSuYTLKUGgGUJuY=; b=nqS8bqx+O0HQrVWu1wucI1/2m0HsRZBcZBpLGKjMtnk3UWR+VuC06EmRIFheOtTMu/ NN7GpoAwoNjNYTMwN22JFFRwi7O2de6dgLUbmRkC6tVO2J8RxrmV24OcDwLrMEhOkfhC VM1DvKLLGp+MkSK/g0WiApyGVil16HqAW+TenfR8OcA+oIZEdq9UBr3P1rb3pO0GuPjp BmNencDpN4QXlkkXiDimY3PBLncAIug7sT0O+d37Nxi2JXpMDb9CgcKQKqYwBn093v5Z bAyYuHkgAjf9bsDhdClV5f0n8vZH2c3mIQzG4owthml1LfJ5b5V54BsgVZO2iO3uOW8N mOWA== 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; bh=izTyuzXMN64QnzTHSBDqz5MmAJ8BHSuYTLKUGgGUJuY=; b=GIC492B5H7EEVlftCPjktYJlKNVxLW6tzm+AO8LwPDRczYVMU1UgVnj/qw9u9BENwQ v6zc1CbOYABb0JNrZLLtsmLRyVkEl43ZYn3TIustLE0suDMnA3eKZCstNAdvUeW4mfq3 cZ9/EBxh74YwROxxbw4xDrgB3bF+bVHbJOBX9QEnKcevcAnG17Ji+EmgOa06a/Zntwj8 /rulD7qJZKIcXQnjIUbfrY2kPr8wi14qCwM2cdhjHu95a14SQN+29HMRTvpxzbj2Bm2T urAsksY6I7NYG6RC/Xfq3Ds51b1voROLXwNdzOM50QYh6ikl8fFUeOljUy0o5AJnw1uu 3U6Q== X-Gm-Message-State: AOAM530aMz4VVemUR00xpTtL2uVqphzAMkn+PtbTmIveZElBnwGcgniH ikWRpJSOTLRelZMKDb7i+jcQtQ== X-Google-Smtp-Source: ABdhPJwgH3jp5Infjsdyk5mitMfInO8xbAhtjSPOyvA1CVIB5O/8ZUipawIzCIbQ9+/dleeP8edXFw== X-Received: by 2002:a17:906:b24d:: with SMTP id ce13mr70708655ejb.546.1594509831578; Sat, 11 Jul 2020 16:23:51 -0700 (PDT) Received: from localhost (ip-86-49-253-141.net.upcbroadband.cz. [86.49.253.141]) by smtp.gmail.com with ESMTPSA id di20sm7806421edb.26.2020.07.11.16.23.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2020 16:23:49 -0700 (PDT) Date: Sun, 12 Jul 2020 01:23:47 +0200 From: Tomas Vondra To: Peter Geoghegan Cc: Stephen Frost , Tom Lane , Jeff Davis , Alvaro Herrera , Andres Freund , Bruce Momjian , Robert Haas , David Rowley , Justin Pryzby , Melanie Plageman , "pgsql-hackers@postgresql.org" Subject: Re: Default setting for enable_hashagg_disk Message-ID: <20200711232347.ptcgo4snunlkay4g@development> References: <20200709225840.GE12375@tamriel.snowman.net> <20200710000842.GF12375@tamriel.snowman.net> <20200710141714.GI12375@tamriel.snowman.net> <20200710215012.GN12375@tamriel.snowman.net> <2165606.1594418399@sss.pgh.pa.us> <20200711142213.GP12375@tamriel.snowman.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sat, Jul 11, 2020 at 09:49:43AM -0700, Peter Geoghegan wrote: >On Sat, Jul 11, 2020 at 7:22 AM Stephen Frost wrote: >> * Tom Lane (tgl@sss.pgh.pa.us) wrote: >> > Have you got a better proposal that is reasonably implementable for v13? >> > (I do not accept the argument that "do nothing" is a better proposal.) > >> So, no, I don't agree that 'do nothing' (except ripping out the one GUC >> that was already added) is a worse proposal than adding another work_mem >> like thing that's only for some nodes types. > >The question was "Have you got a better proposal that is reasonably >implementable for v13?". > >This is anecdotal, but just today somebody on Twitter reported >*increasing* work_mem to stop getting OOMs from group aggregate + >sort: > >https://twitter.com/theDressler/status/1281942941133615104 > >It was possible to fix the problem in this instance, since evidently >there wasn't anything else that really did try to consume ~5 GB of >work_mem memory. Evidently the memory isn't available in any general >sense, so there are no OOMs now. Nevertheless, we can expect OOMs on >this server just as soon as there is a real need to do a ~5GB sort, >regardless of anything else. > I find that example rather suspicious. I mean, what exactly in the GroupAgg plan would consume this memory? Surely it'd have to be some node below the grouping, but sort shouldn't do that, no? Seems strange. >I don't think that this kind of perverse effect is uncommon. Hash >aggregate can naturally be far faster than group agg + sort, Hash agg >can naturally use a lot less memory in many cases, and we have every >reason to think that grouping estimates are regularly totally wrong. >You're significantly underestimating the risk. > I agree grouping estimates are often quite off, and I kinda agree with introducing hash_mem (or at least with the concept that hashing is more sensitive to amount of memory than sort). Not sure it's the right espace hatch to the hashagg spill problem, but maybe it is. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services