Home Explore Blog CI



postgresql

5th chunk of `doc/src/sgml/ref/pg_dump.sgml`
857f8a731fc86d3d75572493b6c14c926850579ff700d4830000000100000fa0

         <listitem>
          <para>
           Output a plain-text <acronym>SQL</acronym> script file (the default).
          </para>
         </listitem>
        </varlistentry>

        <varlistentry>
         <term><literal>c</literal></term>
         <term><literal>custom</literal></term>
         <listitem>
          <para>
           Output a custom-format archive suitable for input into
           <application>pg_restore</application>.
           Together with the directory output format, this is the most flexible
           output format in that it allows manual selection and reordering of
           archived items during restore. This format is also compressed by
           default.
          </para>
         </listitem>
        </varlistentry>

        <varlistentry>
         <term><literal>d</literal></term>
         <term><literal>directory</literal></term>
         <listitem>
          <para>
           Output a directory-format archive suitable for input into
           <application>pg_restore</application>. This will create a directory
           with one file for each table and large object being dumped, plus a
           so-called Table of Contents file describing the dumped objects in a
           machine-readable format that <application>pg_restore</application>
           can read. A directory format archive can be manipulated with
           standard Unix tools; for example, files in an uncompressed archive
           can be compressed with the <application>gzip</application>,
           <application>lz4</application>, or
           <application>zstd</application> tools.
           This format is compressed by default using <literal>gzip</literal>
           and also supports parallel dumps.
          </para>
         </listitem>
        </varlistentry>

        <varlistentry>
         <term><literal>t</literal></term>
         <term><literal>tar</literal></term>
         <listitem>
          <para>
           Output a <command>tar</command>-format archive suitable for input
           into <application>pg_restore</application>. The tar format is
           compatible with the directory format: extracting a tar-format
           archive produces a valid directory-format archive.
           However, the tar format does not support compression. Also, when
           using tar format the relative order of table data items cannot be
           changed during restore.
          </para>
         </listitem>
        </varlistentry>
       </variablelist></para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-j <replaceable class="parameter">njobs</replaceable></option></term>
      <term><option>--jobs=<replaceable class="parameter">njobs</replaceable></option></term>
      <listitem>
       <para>
        Run the dump in parallel by dumping <replaceable class="parameter">njobs</replaceable>
        tables simultaneously. This option may reduce the time needed to perform the dump but it also
        increases the load on the database server. You can only use this option with the
        directory output format because this is the only output format where multiple processes
        can write their data at the same time.
       </para>
       <para><application>pg_dump</application> will open <replaceable class="parameter">njobs</replaceable>
        + 1 connections to the database, so make sure your <xref linkend="guc-max-connections"/>
        setting is high enough to accommodate all connections.
       </para>
       <para>
        Requesting exclusive locks on database objects while running a parallel dump could
        cause the dump to fail. The reason is that the <application>pg_dump</application> leader process
        requests shared locks (<link linkend="locking-tables">ACCESS SHARE</link>) on the
        objects that the worker processes are going to dump later in order to
        make sure that nobody deletes them and makes them go away while the dump is running.
   

Title: pg_dump Output Formats (cont.) and Parallel Dumps (-j/--jobs)
Summary
This section continues describing pg_dump's output formats: directory (d/directory) which creates a directory with files for each table and a table of contents, and tar (t/tar) which creates a tar archive. The tar format is compatible with the directory format but doesn't support compression. It then introduces the -j/--jobs option for parallel dumps, allowing for faster dumping by processing multiple tables simultaneously but increasing the load on the database server. This option is only compatible with the directory output format.