pgsql: Use just one standalone-backend session for initdb's post-bootst - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Use just one standalone-backend session for initdb's post-bootst
Date
Msg-id E1a9j4D-0001x8-8c@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Use just one standalone-backend session for initdb's post-bootstrap steps.

Previously, each subroutine in initdb fired up its own standalone backend
session.  Over time we'd grown as many as fifteen of these sessions,
and the cumulative startup and shutdown work for them was getting pretty
noticeable.  Combining things so that all these steps share a single
backend session cuts a good 10% off the total runtime of initdb, more
if you're not fsync'ing.

The main stumbling block to doing this before was that some of the sessions
were run with -j and some not.  The improved definition of -j mode
implemented by my previous commit makes it possible to fix that by running
all the post-bootstrap steps with -j; we just have to use double instead of
single newlines to end command strings.  (This is only absolutely necessary
around the VACUUM and CREATE DATABASE steps, since those can't be run in a
transaction block.  But it seems best to make them all use double newlines
so that the commands remain separate for error-reporting purposes.)

A minor disadvantage is that since initdb can't tell how much of its
output the backend has executed, we can no longer have the per-step
progress reporting initdb used to print.  But things are fast enough
nowadays that that's not really all that useful anyway.

In passing, add more const decoration to some of the static arrays in
initdb.c.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/c4a8812cf64b142685e39a69694c5276601f40e4

Modified Files
--------------
src/backend/utils/mb/conversion_procs/Makefile |    1 +
src/bin/initdb/initdb.c                        |  487 +++++++-----------------
src/tools/msvc/Install.pm                      |    2 +-
3 files changed, 138 insertions(+), 352 deletions(-)


pgsql-committers by date:

Previous
From: Tom Lane
Date:
Subject: pgsql: Adjust behavior of single-user -j mode for better initdb error r
Next
From: Tom Lane
Date:
Subject: pgsql: Remove unreferenced function declarations.