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 1mS2ND-0003w6-RE for pgsql-performance@arkaria.postgresql.org; Sun, 19 Sep 2021 19:21:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mS2NC-0005ZB-Mh for pgsql-performance@arkaria.postgresql.org; Sun, 19 Sep 2021 19:21:10 +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 1mS2NC-0005VT-EK for pgsql-performance@lists.postgresql.org; Sun, 19 Sep 2021 19:21:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mS2NA-0005hM-18 for pgsql-performance@postgresql.org; Sun, 19 Sep 2021 19:21:09 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 18JJL6HI1566987; Sun, 19 Sep 2021 15:21:06 -0400 From: Tom Lane To: =?UTF-8?Q?Ulf_Lohbr=C3=BCgge?= cc: pgsql-performance@postgresql.org Subject: Re: Query executed during pg_dump leads to excessive memory usage In-reply-to: References: Comments: In-reply-to =?UTF-8?Q?Ulf_Lohbr=C3=BCgge?= message dated "Sun, 19 Sep 2021 12:05:25 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1566985.1632079266.1@sss.pgh.pa.us> Date: Sun, 19 Sep 2021 15:21:06 -0400 Message-ID: <1566986.1632079266@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =?UTF-8?Q?Ulf_Lohbr=C3=BCgge?= writes: > A database cluster (PostgreSQL 12.4 running on Amazon Aurora @ > db.r5.xlarge) with a single database of mine consists of 1,656,618 rows in > pg_class. Ouch. > Using pg_dump on that database leads to excessive memory usage > and sometimes even a kill by signal 9: > 2021-09-18 16:51:24 UTC::@:[29787]:LOG: Aurora Runtime process (PID 29794) > was terminated by signal 9: Killed For the record, Aurora isn't Postgres. It's a heavily-modified fork, with (I imagine) different performance bottlenecks. Likely you should be asking Amazon support about this before the PG community. Having said that ... > The high number of rows in pg_class result from more than ~550 schemata, > each containing more than 600 tables. It's part of a multi tenant setup > where each tenant lives in its own schema. ... you might have some luck dumping each schema separately, or at least in small groups, using pg_dump's --schema switch. > Is there anything I can do to improve that situation? Next thing that comes > to my mind is to distribute those ~550 schemata over 5 to 6 databases in > one database cluster instead of having one single database. Yeah, you definitely don't want to have this many tables in one database, especially not on a platform that's going to be chary of memory. regards, tom lane