Skip to content

Commit 5ab892c

Browse files
committed
Add support for --jobs in reindexdb
When doing a schema-level or a database-level operation, a list of relations to build is created which gets processed in parallel using multiple connections, based on the recent refactoring for parallel slots in src/bin/scripts/. System catalogs are processed first in a serialized fashion to prevent deadlocks, followed by the rest done in parallel. This new option is not compatible with --system as reindexing system catalogs in parallel can lead to deadlocks, and with --index as there is no conflict handling for indexes rebuilt in parallel depending in the same relation. Author: Julien Rouhaud Reviewed-by: Sergei Kornilov, Michael Paquier Discussion: https://postgr.es/m/CAOBaU_YrnH_Jqo46NhaJ7uRBiWWEcS40VNRQxgFbqYo9kApUsg@mail.gmail.com
1 parent 4552c0f commit 5ab892c

File tree

4 files changed

+432
-53
lines changed

4 files changed

+432
-53
lines changed

doc/src/sgml/ref/reindexdb.sgml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,29 @@ PostgreSQL documentation
166166
</listitem>
167167
</varlistentry>
168168

169+
<varlistentry>
170+
<term><option>-j <replaceable class="parameter">njobs</replaceable></option></term>
171+
<term><option>--jobs=<replaceable class="parameter">njobs</replaceable></option></term>
172+
<listitem>
173+
<para>
174+
Execute the reindex commands in parallel by running
175+
<replaceable class="parameter">njobs</replaceable>
176+
commands simultaneously. This option reduces the time of the
177+
processing but it also increases the load on the database server.
178+
</para>
179+
<para>
180+
<application>reindexdb</application> will open
181+
<replaceable class="parameter">njobs</replaceable> connections to the
182+
database, so make sure your <xref linkend="guc-max-connections"/>
183+
setting is high enough to accommodate all connections.
184+
</para>
185+
<para>
186+
Note that this option is incompatible with the <option>--index</option>
187+
and <option>--system</option> options.
188+
</para>
189+
</listitem>
190+
</varlistentry>
191+
169192
<varlistentry>
170193
<term><option>-q</option></term>
171194
<term><option>--quiet</option></term>

src/bin/scripts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dropdb: dropdb.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-
2929
dropuser: dropuser.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
3030
clusterdb: clusterdb.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
3131
vacuumdb: vacuumdb.o common.o scripts_parallel.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
32-
reindexdb: reindexdb.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
32+
reindexdb: reindexdb.o common.o scripts_parallel.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
3333
pg_isready: pg_isready.o common.o $(WIN32RES) | submake-libpq submake-libpgport submake-libpgfeutils
3434

3535
install: all installdirs

0 commit comments

Comments
 (0)