Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sXRfv-0044y3-Rd for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jul 2024 20:36:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sXRfu-0004pA-90 for pgsql-hackers@arkaria.postgresql.org; Fri, 26 Jul 2024 20:36:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sXRft-0004nk-VX for pgsql-hackers@lists.postgresql.org; Fri, 26 Jul 2024 20:36:25 +0000 Received: from charmander.telsasoft.com ([50.244.222.1] helo=pryzbyj2023.telsasoft) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sXRfr-001dVQ-Q4 for pgsql-hackers@postgresql.org; Fri, 26 Jul 2024 20:36:25 +0000 Received: by pryzbyj2023.telsasoft (Postfix, from userid 1000) id B5D3C34E1; Fri, 26 Jul 2024 15:36:20 -0500 (CDT) Date: Fri, 26 Jul 2024 15:36:20 -0500 From: Justin Pryzby To: Alexander Korotkov Cc: Tom Lane , Nathan Bossart , Michael Banck , Laurenz Albe , vignesh C , "Kumar, Sachin" , Robins Tharakan , Jan Wieck , Bruce Momjian , Andrew Dunstan , Magnus Hagander , Peter Eisentraut , pgsql-hackers@postgresql.org Subject: Re: pg_upgrade failing for 200+ million Large Objects Message-ID: References: <4a3ebf7d81bfc6dd4d545e5b27d6e8f6c32d8937.camel@cybertec.at> <3023817.1710629175@sss.pgh.pa.us> <6603e4e0.500a0220.a557f.4f39@mx.google.com> <3304322.1711551245@sss.pgh.pa.us> <20240327150826.GB3994937@nathanxps13> <20240401191930.GA2302032@nathanxps13> <1217588.1711999706@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jul 24, 2024 at 09:17:51AM -0500, Justin Pryzby wrote: > With partitioning, we have a lot of tables, some of them wide (126 > partitioned tables, 8942 childs, total 1019315 columns). On Fri, Jul 26, 2024 at 10:53:30PM +0300, Alexander Korotkov wrote: > It would be nice to identify such cases and check which memory contexts are > growing and why. I reproduced the problem with this schema: SELECT format('CREATE TABLE p(i int, %s) PARTITION BY RANGE(i)', array_to_string(a, ', ')) FROM (SELECT array_agg(format('i%s int', i))a FROM generate_series(1,999)i); SELECT format('CREATE TABLE t%s PARTITION OF p FOR VALUES FROM (%s)TO(%s)', i,i,i+1) FROM generate_series(1,999)i; This used over 4 GB of RAM. 3114201 pryzbyj 20 0 5924520 4.2g 32476 T 0.0 53.8 0:27.35 postgres: pryzbyj postgres [local] UPDATE The large context is: 2024-07-26 15:22:19.280 CDT [3114201] LOG: level: 1; CacheMemoryContext: 5211209088 total in 50067 blocks; 420688 free (14 chunks); 5210788400 used Note that there seemed to be no issue when I created 999 tables without partitioning: SELECT format('CREATE TABLE t%s(LIKE p)', i,i,i+1) FROM generate_series(1,999)i; -- Justin