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 1v99T7-00ApPa-2A for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Oct 2025 21:55:36 +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 1v99T4-008ZKD-WE for pgsql-bugs@arkaria.postgresql.org; Wed, 15 Oct 2025 21:55:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v99T4-008ZJR-Nv for pgsql-bugs@lists.postgresql.org; Wed, 15 Oct 2025 21:55:33 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v99T2-001yMe-0U for pgsql-bugs@lists.postgresql.org; Wed, 15 Oct 2025 21:55:32 +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 59FLtSkx1324004; Wed, 15 Oct 2025 17:55:28 -0400 From: Tom Lane To: David Rowley cc: Nathan Bossart , andrewbille@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables. In-reply-to: References: <19086-871ff11017d03dc5@postgresql.org> <1000041.1760471415@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Thu, 16 Oct 2025 10:38:09 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1324002.1760565328.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 15 Oct 2025 17:55:28 -0400 Message-ID: <1324003.1760565328@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > Seems to be due to pg_get_indexdef / pg_get_constraintdef operating on > a cold cat cache. Getting rid of those the rewritten version runs in > 1.8 seconds with 100k tables for me. I wonder how much win could be had by postponing those function calls so that they only act on indexes we're going to dump. It might be a net loss in the default dump-everything case, though. Also, it looks to me like getIndexes does not even look at the result of pg_get_constraintdef unless contype =3D=3D 'x'. So there should be some low-hanging fruit with - "pg_catalog.pg_get_constraintdef(c.oid, false) A= S condef, " + "CASE WHEN c.contype =3D 'x' THEN " + "pg_catalog.pg_get_constraintdef(c.oid, false) " + "END AS condef, " This wouldn't matter except with primary/unique constraints, but surely there are plenty of those in a typical DB. regards, tom lane