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 1k387H-00038b-1j for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2020 01:21:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k387E-0004xB-UC for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2020 01:21:12 +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 1k387E-0004x4-Mr for pgsql-hackers@lists.postgresql.org; Wed, 05 Aug 2020 01:21:12 +0000 Received: from mail-il1-x143.google.com ([2607:f8b0:4864:20::143]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k387B-0005a2-JE for pgsql-hackers@postgresql.org; Wed, 05 Aug 2020 01:21:11 +0000 Received: by mail-il1-x143.google.com with SMTP id j9so32559404ilc.11 for ; Tue, 04 Aug 2020 18:21:09 -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:mime-version:content-disposition :user-agent; bh=xDlrLOCGWobsmK7qz9fLVRzVaHRsNxltViJdD+Nv7F4=; b=b3hy/gIGNqe6qmfjsKy0t54ncmi2GTMouDT1imXWbDp4ZPMsLOfWGWym9bVj232hJx XOZRxXvaj+qrExLMvx4rT8NWTY+zJCPI1NJDdzVpUFKfiV3L3GA9lWiiANEZpis8IAWT vO4XG2JfKx9WJ2IH4ApjXL9YMx/jaTOjq0fBSwZ9mQdo+LhmKl6SGO0uN7d0/mmkks8o gPyoQJy/o/E33n/8gSr4iAaR9cOBRVfP/2Z4zttAu5PlCSjtoNywOI3EKrDMgb6tT43Q fVOdJV1ASoFDuW78hPaxgEBMOO/StrMEcGBbNOPREZjh59vYRRSWUN4T0C+ImXdVrEyX 3UkQ== 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:mime-version :content-disposition:user-agent; bh=xDlrLOCGWobsmK7qz9fLVRzVaHRsNxltViJdD+Nv7F4=; b=p+Zn3n65q6cx9zhJJQwl4JwXvJPaMMri2a+0UoeO9xTgR+tMxEfWCYp4GPOP5PGBgv KhUgX/rkHQCRohQxqow99nS2zH7Uh24/cl+OEbAkvQPZkqp+qs38tKS7Tr7X6DvcfE74 pDfq9uJlZKWBG5nbHjL6iTkCu5TQTzJDVc60xKvSlQB0walj07OmK20vSqpEwi2yPtke +Hvu2iFItvkwABaSc+TvFnTxHfXzCWVgHQO85PcF9CeuIm1Mwb5qpQKHLw29uAOcXenR qmRumDQb1ABS0n5R8yY5pogrCfdNEggwc4V2Wv3whI3jciHhH7CbbA6zZGe0JGQsn1Zl v0wg== X-Gm-Message-State: AOAM531MmYFFlpoOaWOmJ0zhLJ5nCEN32a5M7bs0lZ4Uq/ZFi/4B2Jiv Pshs1i6DpKJHnEK1sC3KZ8GuiuAdO3o= X-Google-Smtp-Source: ABdhPJxVFeU4GsR+2IxDfppZfcM5+pk0XAw4yrAbO3xtSypF7EziHprAn7Ghxxgfuwf2HC5nsiWv4w== X-Received: by 2002:a92:c90c:: with SMTP id t12mr1397832ilp.7.1596590467769; Tue, 04 Aug 2020 18:21:07 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id x14sm359864ilm.31.2020.08.04.18.21.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Aug 2020 18:21:07 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id E943380015E; Tue, 4 Aug 2020 20:21:05 -0500 (CDT) Date: Tue, 4 Aug 2020 20:21:05 -0500 From: Justin Pryzby To: pgsql-hackers@postgresql.org Cc: David Rowley , Jeff Davis Subject: pg13dev: explain partial, parallel hashagg, and memory use Message-ID: <20200805012105.GZ28072@telsasoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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. CREATE TABLE p(i int) PARTITION BY RANGE(i); CREATE TABLE p1 PARTITION OF p FOR VALUES FROM (0)TO(1000); CREATE TABLE p2 PARTITION OF p FOR VALUES FROM (1000)TO(2000); CREATE TABLE p3 PARTITION OF p FOR VALUES FROM (2000)TO(3000); INSERT INTO p SELECT i%3000 FROM generate_series(1,999999)i; VACUUM ANALYZE p; postgres=# explain(analyze,settings) SELECT i, COUNT(1) FROM p GROUP BY 1; QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------- Gather (cost=7469.00..14214.45 rows=2502 width=12) (actual time=489.409..514.209 rows=3000 loops=1) Workers Planned: 2 Workers Launched: 2 -> Parallel Append (cost=6469.00..12964.25 rows=1251 width=12) (actual time=476.291..477.179 rows=1000 loops=3) -> HashAggregate (cost=6487.99..6497.99 rows=1000 width=12) (actual time=474.454..475.203 rows=1000 loops=1) Group Key: p.i Batches: 1 Memory Usage: 0kB Worker 0: Batches: 1 Memory Usage: 193kB Worker 1: Batches: 1 Memory Usage: 0kB -> Seq Scan on p1 p (cost=0.00..4817.99 rows=333999 width=4) (actual time=0.084..100.677 rows=333999 loops=1) -> HashAggregate (cost=6469.00..6479.00 rows=1000 width=12) (actual time=468.517..469.272 rows=1000 loops=1) Group Key: p_1.i Batches: 1 Memory Usage: 0kB Worker 0: Batches: 1 Memory Usage: 0kB Worker 1: Batches: 1 Memory Usage: 193kB -> Seq Scan on p2 p_1 (cost=0.00..4804.00 rows=333000 width=4) (actual time=0.082..102.154 rows=333000 loops=1) -> HashAggregate (cost=6469.00..6479.00 rows=1000 width=12) (actual time=485.887..486.509 rows=1000 loops=1) Group Key: p_2.i Batches: 1 Memory Usage: 193kB Worker 0: Batches: 1 Memory Usage: 0kB Worker 1: Batches: 1 Memory Usage: 0kB -> Seq Scan on p3 p_2 (cost=0.00..4804.00 rows=333000 width=4) (actual time=0.043..104.631 rows=333000 loops=1) Settings: effective_io_concurrency = '0', enable_partitionwise_aggregate = 'on', enable_partitionwise_join = 'on', work_mem = '127MB' -- Justin