Skip to content

Commit 34eb2a8

Browse files
committed
Change pg_dump default for statistics export.
Set the default behavior of pg_dump and pg_dumpall to be --no-statistics. Leave the default for pg_restore and pg_upgrade to be --with-statistics. Discussion: https://postgr.es/m/CA+TgmoZ9=RnWcCOZiKYYjZs_AW1P4QXCw--h4dOLLHuf1Omung@mail.gmail.com Reviewed-by: Greg Sabino Mullane <htamfids@gmail.com> Reviewed-by: Nathan Bossart <nathandbossart@gmail.com> Reviewed-by: Robert Haas <robertmhaas@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
1 parent 4c08ecd commit 34eb2a8

File tree

5 files changed

+81
-22
lines changed

5 files changed

+81
-22
lines changed

doc/src/sgml/ref/pg_dump.sgml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ PostgreSQL documentation
11341134
<term><option>--no-statistics</option></term>
11351135
<listitem>
11361136
<para>
1137-
Do not dump statistics.
1137+
Do not dump statistics. This is the default.
11381138
</para>
11391139
</listitem>
11401140
</varlistentry>
@@ -1461,7 +1461,7 @@ PostgreSQL documentation
14611461
<term><option>--with-statistics</option></term>
14621462
<listitem>
14631463
<para>
1464-
Dump statistics. This is the default.
1464+
Dump statistics.
14651465
</para>
14661466
</listitem>
14671467
</varlistentry>
@@ -1681,14 +1681,14 @@ CREATE DATABASE foo WITH TEMPLATE template0;
16811681
</para>
16821682

16831683
<para>
1684-
By default, <command>pg_dump</command> will include most optimizer
1685-
statistics in the resulting dump file. However, some statistics may not be
1686-
included, such as those created explicitly with <xref
1687-
linkend="sql-createstatistics"/> or custom statistics added by an
1688-
extension. Therefore, it may be useful to run <command>ANALYZE</command>
1689-
after restoring from a dump file to ensure optimal performance; see <xref
1690-
linkend="vacuum-for-statistics"/> and <xref linkend="autovacuum"/> for more
1691-
information.
1684+
If <option>--with-statistics</option> is specified,
1685+
<command>pg_dump</command> will include most optimizer statistics in the
1686+
resulting dump file. However, some statistics may not be included, such as
1687+
those created explicitly with <xref linkend="sql-createstatistics"/> or
1688+
custom statistics added by an extension. Therefore, it may be useful to
1689+
run <command>ANALYZE</command> after restoring from a dump file to ensure
1690+
optimal performance; see <xref linkend="vacuum-for-statistics"/> and <xref
1691+
linkend="autovacuum"/> for more information.
16921692
</para>
16931693

16941694
<para>

doc/src/sgml/ref/pg_dumpall.sgml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,7 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
567567
<term><option>--no-statistics</option></term>
568568
<listitem>
569569
<para>
570-
Do not dump statistics.
570+
Do not dump statistics. This is the default.
571571
</para>
572572
</listitem>
573573
</varlistentry>
@@ -741,7 +741,7 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
741741
<term><option>--with-statistics</option></term>
742742
<listitem>
743743
<para>
744-
Dump statistics. This is the default.
744+
Dump statistics.
745745
</para>
746746
</listitem>
747747
</varlistentry>
@@ -957,14 +957,14 @@ exclude database <replaceable class="parameter">PATTERN</replaceable>
957957
</para>
958958

959959
<para>
960-
By default, <command>pg_dumpall</command> will include most optimizer
961-
statistics in the resulting dump file. However, some statistics may not be
962-
included, such as those created explicitly with <xref
963-
linkend="sql-createstatistics"/> or custom statistics added by an
964-
extension. Therefore, it may be useful to run <command>ANALYZE</command>
965-
on each database after restoring from a dump file to ensure optimal
966-
performance. You can also run <command>vacuumdb -a -z</command> to analyze
967-
all databases.
960+
If <option>--with-statistics</option> is specified,
961+
<command>pg_dumpall</command> will include most optimizer statistics in the
962+
resulting dump file. However, some statistics may not be included, such as
963+
those created explicitly with <xref linkend="sql-createstatistics"/> or
964+
custom statistics added by an extension. Therefore, it may be useful to
965+
run <command>ANALYZE</command> on each database after restoring from a dump
966+
file to ensure optimal performance. You can also run <command>vacuumdb -a
967+
-z</command> to analyze all databases.
968968
</para>
969969

970970
<para>

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ InitDumpOptions(DumpOptions *opts)
152152
opts->dumpSections = DUMP_UNSECTIONED;
153153
opts->dumpSchema = true;
154154
opts->dumpData = true;
155-
opts->dumpStatistics = true;
155+
opts->dumpStatistics = false;
156156
}
157157

158158
/*

0 commit comments

Comments
 (0)