From: Andrew Dunstan <andrew@dunslane.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Noah Misch <noah@leadboat.com>
Cc: Melanie Plageman <melanieplageman@gmail.com>
Cc: gonzalemario@gmail.com
Cc: dbryan.green@gmail.com
Cc: euler@eulerto.com
Cc: pgsql-hackers@postgresql.org
Subject: Re: pg_get_*_ddl() needs a redesign
Date: Sat, 12 Sep 2026 10:02:59 -0400
Message-ID: <c51c8535-5f75-46fd-b4ef-eaa304f9311a@dunslane.net> (raw)
In-Reply-To: <956966.1789102554@sss.pgh.pa.us>
References: <20260827015242.54.noahmisch@microsoft.com>
<CAAKRu_a0KX2OONvtcEOwyOX0DzOC-B8sh-w8s5tNkKwczmVzeQ@mail.gmail.com>
<c75aa91a-7029-4c69-9f98-fe4d2f18bc11@dunslane.net>
<20260909172132.0a.noahmisch@microsoft.com>
<640139.1788975299@sss.pgh.pa.us>
<ccd76a86-51c0-4395-b6b2-2e7214c2fbf2@dunslane.net>
<20260910035953.59.noahmisch@microsoft.com>
<CA+Tgmoa2aBFUREeN1AWZ9O8h5WjTD0wdwAzDJj4c3j5aOP=eTA@mail.gmail.com>
<956966.1789102554@sss.pgh.pa.us>
On 2026-09-11 Fr 12:55 AM, Tom Lane wrote:
> The hard parts as I see it are
>
> (A) pg_dump is optimized to gather data across the entire database
> at once. Converting it to call functions that produce info about
> a single object at a time would almost certainly be catastrophic
> for performance on large databases.
>
> (B) pg_dump slices and dices the data in ways that don't necessarily
> make sense for standalone usage. For example it doesn't want to
> mention a primary key when creating a table, rather it wants to add
> that constraint (and build the index) after loading data.
>
> I do not feel that these problems are necessarily insoluble, but
> they do require some hard work to define the server-side functionality
> properly.
>
>
I think you've put your finger on some of the main issues. The main use
case in my mind from the get go was not "How do we make this work for
pg_dump?" but "I want to create an object that's like this thing but a
bit different. Give me the DDL for this thing so I can tinker with it."
That's the use case that people just about always give me when I've
talked to them about this.
Maybe point A is not insoluble, but I've thought all along that it was a
pretty significant barrier, and I don't have a good solution for it.
Making this feature contingent on solving that problem would sacrifice
the originally intended use case, which would be very sad.
Your point B is also well taken. pg_dump formats and arranges the SQL to
suit its purposes, but that should not be taken as the canonical
arrangement for other uses. Perhaps these functions should have a "dump"
flavor that produces output like pg_dump/all.
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: andrew@dunslane.net, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, noah@leadboat.com, melanieplageman@gmail.com, gonzalemario@gmail.com, dbryan.green@gmail.com, euler@eulerto.com
Subject: Re: pg_get_*_ddl() needs a redesign
In-Reply-To: <c51c8535-5f75-46fd-b4ef-eaa304f9311a@dunslane.net>
References: <20260827015242.54.noahmisch@microsoft.com> <CAAKRu_a0KX2OONvtcEOwyOX0DzOC-B8sh-w8s5tNkKwczmVzeQ@mail.gmail.com> <c75aa91a-7029-4c69-9f98-fe4d2f18bc11@dunslane.net> <20260909172132.0a.noahmisch@microsoft.com> <640139.1788975299@sss.pgh.pa.us> <ccd76a86-51c0-4395-b6b2-2e7214c2fbf2@dunslane.net> <20260910035953.59.noahmisch@microsoft.com> <CA+Tgmoa2aBFUREeN1AWZ9O8h5WjTD0wdwAzDJj4c3j5aOP=eTA@mail.gmail.com> <956966.1789102554@sss.pgh.pa.us> <c51c8535-5f75-46fd-b4ef-eaa304f9311a@dunslane.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox