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 1joVTk-0002ZR-GK for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 17:16:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1joVTj-0006ea-C3 for pgsql-hackers@arkaria.postgresql.org; Thu, 25 Jun 2020 17:15:59 +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 1joVTi-0006dG-W0 for pgsql-hackers@lists.postgresql.org; Thu, 25 Jun 2020 17:15:59 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1joVTg-0008R5-Of for pgsql-hackers@postgresql.org; Thu, 25 Jun 2020 17:15:57 +0000 Received: by mail-pf1-x430.google.com with SMTP id f9so3331313pfn.0 for ; Thu, 25 Jun 2020 10:15:56 -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=TFpxROXcgHpV5iFGqeufEf1N4G/mAU86XTbRI00M1WM=; b=d0yYw54aVr0/ttdg6dxFQJ7dLtSYRqpwbJWdEMD6HzWj969/kGHj0xrLNGota4LMdQ igYIw48T/2jWlrR0Muj+FkOYVZNVuEDAFiePuw8RIy325IWrbXhMmI1+oFXKwEVa1nH3 75wipQTsgWMM5D47Pn/CREbaf8sv9wMA+cbWnZu5IwQ6/VzkX+djKVCXQ6EkzPXsuufi 0czH8xFwfxvvXM9Klp1zpcUzDacLGPBfSydNn1ZRPD8eFV2EfdcsDWm6FLIrISpsu1LU 2qEYSdaM0QUnBCL104MtLjDvbvBtMc4ax9PiIzTFgFfVGvXjjK/CShcQYqS1PjRzxEoR LZDg== 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=TFpxROXcgHpV5iFGqeufEf1N4G/mAU86XTbRI00M1WM=; b=Dzy8HBaWTOVXJ9DGCc4Xc67+vYGh7LJ3BTLPPDQz8uqBdSgbh9nDZAV6t1+WBYG3PV LEwk+z+Sq8sCCsr8NvjMeLhyWq76jUcFVHftSP5yQmVD1R4xhnvQuJSADPQGMnTSRstP lvrbjhQisxlH9aoIr4iOQF9QyCMyuM8rc3fa2rosxwtDpXD2Fj5jLzmYThLj2PxqUBj9 bvPZYaBq9mY9r5fJl0mt6gkXOT9OHnW9P7RvoG/3ZplnMYgo/Htut5tX49jcS5NVwuc1 89j9zeI2q6vu1OSaHQGd6UW+sVl/igBj2HoWUQs36pQ64v+kSx7ZjmgncvhU1B71Px/+ kwJQ== X-Gm-Message-State: AOAM531BGidM1+PgyPhuS6y0Bz9QnKiZHlu535JeYp1uQgOFQlQhTzb4 1O/vV/gFe4xmWfhnXUlXlcZaJQ== X-Google-Smtp-Source: ABdhPJzg2l0/QmhjgX/MFxGwmH+hLzRZhl6CZATgsYTUS7WVNXYVzEbNyVffIZJp8xUajgHGHmLPVg== X-Received: by 2002:a62:1d81:: with SMTP id d123mr26603770pfd.38.1593105355358; Thu, 25 Jun 2020 10:15:55 -0700 (PDT) Received: from jdavis.lan (c-73-231-146-4.hsd1.ca.comcast.net. [73.231.146.4]) by smtp.gmail.com with ESMTPSA id n9sm9692916pjj.23.2020.06.25.10.15.53 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 25 Jun 2020 10:15:54 -0700 (PDT) Message-ID: <2401e86059624be1917fd0fbcd08700f52f2ba12.camel@j-davis.com> Subject: Re: Default setting for enable_hashagg_disk From: Jeff Davis To: Robert Haas , Bruce Momjian Cc: Andres Freund , David Rowley , Justin Pryzby , Melanie Plageman , Tomas Vondra , "pgsql-hackers@postgresql.org" Date: Thu, 25 Jun 2020 10:15:52 -0700 In-Reply-To: References: <129c8f1739957589584d9525e1d8782eae3f412f.camel@j-davis.com> <20200624090628.GA19640@momjian.us> <20200624171203.GB17842@momjian.us> <20200624191900.t4sbfk236gndwoa3@alap3.anarazel.de> <20200624231810.GB13627@momjian.us> <20200624233837.GA21436@momjian.us> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Thu, 2020-06-25 at 11:46 -0400, Robert Haas wrote: > Because the first problem is so bad, most people > set the value relatively conservatively and just live with the > performance consequences. But this also means that they have memory > left over most of the time, so the idea of letting a node burst above > its work_mem allocation when something unexpected happens isn't > crazy: > as long as only a few nodes do that here and there, rather than, say, > all the nodes doing it all at the same time, it's actually fine. Unexpected things (meaning underestimates) are not independent. All the queries are based on the same stats, so if you have a lot of similar queries, they will all get the same underestimate at once, and all be surprised when they need to spill at once, and then all decide they are entitled to ignore work_mem at once. > If we > had a smarter system that could dole out more work_mem to nodes that > would really benefit from it and less to nodes where it isn't likely > to make much difference, that would be similar in spirit but even > better. That sounds more useful and probably not too hard to implement in a crude form. Just have a shared counter in memory representing GB. If a node is about to spill, it could try to decrement the counter by N, and if it succeeds, it gets to exceed work_mem by N more GB. Regards, Jeff Davis