• Tom Lane's avatar
    Use just one standalone-backend session for initdb's post-bootstrap steps. · c4a8812c
    Tom Lane authored
    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.
    c4a8812c
Install.pm 18.1 KB