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 1k38vn-00057U-QS for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2020 02:13:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k38vm-0003QY-Fu for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2020 02:13:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k38vm-0003QQ-5I for pgsql-hackers@lists.postgresql.org; Wed, 05 Aug 2020 02:13:26 +0000 Received: from mail-io1-xd42.google.com ([2607:f8b0:4864:20::d42]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k38vj-000656-2B for pgsql-hackers@postgresql.org; Wed, 05 Aug 2020 02:13:25 +0000 Received: by mail-io1-xd42.google.com with SMTP id g14so6849336iom.0 for ; Tue, 04 Aug 2020 19:13:22 -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=mGgkdb/UBqijPxgepuauTi3uwQ9IXBI9yxm/nWrVino=; b=jHLqYSZRe0o1IlP0stMCx2IqKl2pD1yJ/VemnuWm3k42l0C1UEtVhF8ms/cf86HCuK PB5vNoQ1d3IONqYE8w3p042FZ2Tjj4YyRGLSWfp1Nc6uAjzYyJdB9BE5WIPLVF3LU/5k 899JzYGeSbjioZCysKZ/6sjnAvwVeLn7AtD5SoXov6KylJaVrWxnw53wJJZRcW0CGjng WJI8fjO4hhITb96/WsjR9uh1T2EgKIKcNXdxoiKZXxKoYp3Vl5wC8DvZocr5TgQh2aqM 5xqVqiFs0BoTE62mJW3hF+muSW7tNpP/aIWiJRxQe1l7TBr2H1052PD5Cx4M4oTpiIak CkbA== 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=mGgkdb/UBqijPxgepuauTi3uwQ9IXBI9yxm/nWrVino=; b=MVPxorULt8sEGMdNCscF9BbYLUgIwiM9q7uw0OWtqnXHdNDiph+93ga+jqBPDgJ+Xy ucUFBjuYdKpKJQ2ymRBGf+WOAM23oDziZCsqJWRnMxJvaW+yD1Snm6pGb3MSw5CGMPsY CWJX7pE/9Ubr78CoovzKRuV/yx62Cb4RPyx/X5PKv91zwmDf4jXU/anVe9ea/yYCIsQH gRVzgOynanEjwTSGA3Bqr49dR21HZ/j/vXZtFNdrXJMts6vVry9Lm7sUx3zyNqUaoNpI pXE6iEa7w8a1unQn3F/BUZF9vJGAcPJR4PKQW6CU2F2BjN+dnDA7DgpZltrG0bcJl91K 1b3g== X-Gm-Message-State: AOAM532bv/qX4F/qTHA4Kpb9OoZxpTgGEbXLb9+XY0N4eMB3MYRyYrUg GqwRKGx7DSNV+ZQa5m8a/TyHjg== X-Google-Smtp-Source: ABdhPJzUs2OeumJNKDuPWltKgUKp2J2atxWUUHPVmuXVGdmMWKaGTMxg5nZjrBYTbuqkejdVAo0eAQ== X-Received: by 2002:a02:17c2:: with SMTP id 185mr1427348jah.65.1596593601597; Tue, 04 Aug 2020 19:13:21 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id 186sm472949ila.0.2020.08.04.19.13.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2020 19:13:20 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id 755DD800185; Tue, 4 Aug 2020 21:13:19 -0500 (CDT) Date: Tue, 4 Aug 2020 21:13:19 -0500 From: Justin Pryzby To: David Rowley Cc: pgsql-hackers@postgresql.org, Jeff Davis Subject: Re: pg13dev: explain partial, parallel hashagg, and memory use Message-ID: <20200805021319.GA28072@telsasoft.com> References: <20200805012105.GZ28072@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 Wed, Aug 05, 2020 at 01:44:17PM +1200, David Rowley wrote: > On Wed, 5 Aug 2020 at 13:21, Justin Pryzby wrote: > > > > I'm testing with a customer's data on pg13dev and got output for which Peak > > Memory doesn't look right/useful. I reproduced it on 565f16902. > > Likely the sanity of those results depends on whether you think that > the Memory Usage reported outside of the workers is meant to be the > sum of all processes or the memory usage for the leader backend. > > All that's going on here is that the Parallel Append is using some > parallel safe paths and giving one to each worker. The 2 workers take > the first 2 subpaths and the leader takes the third. The memory usage > reported helps confirm that's the case. I'm not sure there's a problem, but all the 0kB were suspicious to me. I think you're saying that one worker alone handled each HashAgg, and the other worker (and leader) show 0kB. I guess in my naive thinking it's odd to show a worker which wasn't active for that subpath (at least in text output). But I don't know the expected behavior of parallel hashagg, so that explains most of my confusion. On Tue, Aug 04, 2020 at 10:01:18PM -0400, James Coleman wrote: > Perhaps it could also say "Participating" or "Non-participating"? Yes, that'd help me alot :) Also odd (to me). If I encourage more workers, there are "slots" for each "planned" worker, even though fewer were launched: postgres=# ALTER TABLE p3 SET (parallel_workers=11); postgres=# SET max_parallel_workers_per_gather=11; Finalize HashAggregate (cost=10299.64..10329.64 rows=3000 width=12) (actual time=297.793..299.933 rows=3000 loops=1) Group Key: p.i Batches: 1 Memory Usage: 625kB -> Gather (cost=2928.09..10134.64 rows=33000 width=12) (actual time=233.398..282.429 rows=13000 loops=1) Workers Planned: 11 Workers Launched: 7 -> Parallel Append (cost=1928.09..5834.64 rows=3000 width=12) (actual time=214.358..232.980 rows=1625 loops=8) -> Partial HashAggregate (cost=1933.46..1943.46 rows=1000 width=12) (actual time=167.936..171.345 rows=1000 loops=4) Group Key: p.i Batches: 1 Memory Usage: 0kB Worker 0: Batches: 1 Memory Usage: 193kB Worker 1: Batches: 1 Memory Usage: 193kB Worker 2: Batches: 1 Memory Usage: 0kB Worker 3: Batches: 1 Memory Usage: 0kB Worker 4: Batches: 1 Memory Usage: 193kB Worker 5: Batches: 1 Memory Usage: 0kB Worker 6: Batches: 1 Memory Usage: 193kB Worker 7: Batches: 0 Memory Usage: 0kB Worker 8: Batches: 0 Memory Usage: 0kB Worker 9: Batches: 0 Memory Usage: 0kB Worker 10: Batches: 0 Memory Usage: 0kB Thanks, -- Justin