From: Julien Rouhaud <rjuju123@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Subject: Avoid useless retrieval of defaults and check constraints in pg_dump -a
Date: Sun, 12 Jul 2020 07:48:50 +0200
Message-ID: <20200712054850.GA92357@nol> (raw)
Hi,
Currently, getTableAttrs() always retrieves info about columns defaults and
check constraints, while this will never be used if --data-only option if used.
This seems like a waste of resources, so here's a patch to skip those parts
when the DDL won't be generated.
Attachments:v1-pg_dump_data_only.diff (text/plain, 689B) downloaddiff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.cindex e758b5c50a..e4ea604dfe 100644--- a/src/bin/pg_dump/pg_dump.c+++ b/src/bin/pg_dump/pg_dump.c@@ -8590,7 +8590,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
/*
* Get info about column defaults
*/
- if (hasdefaults)+ if (!dopt->dataOnly && hasdefaults)
{
AttrDefInfo *attrdefs;
int numDefaults;
@@ -8677,7 +8677,7 @@ getTableAttrs(Archive *fout, TableInfo *tblinfo, int numTables)
/*
* Get info about table CHECK constraints
*/
- if (tbinfo->ncheck > 0)+ if (!dopt->dataOnly && tbinfo->ncheck > 0)
{
ConstraintInfo *constrs;
int numConstrs;
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: rjuju123@gmail.com
Subject: Re: Avoid useless retrieval of defaults and check constraints in pg_dump -a
In-Reply-To: <20200712054850.GA92357@nol>
References: <20200712054850.GA92357@nol>
* 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