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 1mKLEL-0000O6-Gb for pgsql-general@arkaria.postgresql.org; Sun, 29 Aug 2021 13:52:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mKLEK-0001gk-9m for pgsql-general@arkaria.postgresql.org; Sun, 29 Aug 2021 13:52:12 +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 1mKLEJ-0001gc-L4 for pgsql-general@lists.postgresql.org; Sun, 29 Aug 2021 13:52:11 +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 1mKLED-0005jK-D3 for pgsql-general@lists.postgresql.org; Sun, 29 Aug 2021 13:52:10 +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 17TDpwaL1124942; Sun, 29 Aug 2021 09:51:58 -0400 From: Tom Lane To: Alvaro Herrera cc: depesz@depesz.com, Stephen Frost , Laurenz Albe , pgsql-general Subject: Re: Can we get rid of repeated queries from pg_dump? In-reply-to: <202108291313.oufovwqmwm67@alvherre.pgsql> References: <202108291313.oufovwqmwm67@alvherre.pgsql> Comments: In-reply-to Alvaro Herrera message dated "Sun, 29 Aug 2021 09:13:15 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1124940.1630245118.1@sss.pgh.pa.us> Date: Sun, 29 Aug 2021 09:51:58 -0400 Message-ID: <1124941.1630245118@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Alvaro Herrera writes: > Another pointlessly repetitive query is in getTriggers, which we run > once per table to be dumped containing triggers. We could reduce that > by running it in bulk for many relations at a time. I suppose it's > normally not hurtful, but as we grow the number of partitions we allow > it's going to become a problem. Perhaps. In the regression database, only ~10% of the tables have triggers, so it's likely not going to yield any measurable gain there. But databases that make heavier use of foreign keys might see a win. Another thing I've wondered about before is whether it could make sense to read pg_attribute once rather than once per table. There might be a fair amount of wasted work if the dump is selective, and in big DBs the sheer size of that result could be a problem. But those reads are definitely way up there on the number-of-queries scale. regards, tom lane