1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Make pgbench vacuum before building indexes.

This is apparently faster than doing things the other way around when
the scale factor is large.

Along the way, adjust -n to suppress vacuuming during initialization
as well as during test runs.

Jeff Janes, with some small changes by me.
This commit is contained in:
Robert Haas
2012-07-23 14:38:34 -04:00
parent b71258af56
commit 46b2b7e0ff
2 changed files with 22 additions and 8 deletions

View File

@ -345,6 +345,7 @@ usage(void)
" %s [OPTION]... [DBNAME]\n" " %s [OPTION]... [DBNAME]\n"
"\nInitialization options:\n" "\nInitialization options:\n"
" -i invokes initialization mode\n" " -i invokes initialization mode\n"
" -n do not run VACUUM after initialization\n"
" -F NUM fill factor\n" " -F NUM fill factor\n"
" -s NUM scaling factor\n" " -s NUM scaling factor\n"
" --foreign-keys\n" " --foreign-keys\n"
@ -1282,7 +1283,7 @@ disconnect_all(CState *state, int length)
/* create tables and setup data */ /* create tables and setup data */
static void static void
init(void) init(bool is_no_vacuum)
{ {
/* /*
* Note: TPC-B requires at least 100 bytes per row, and the "filler" * Note: TPC-B requires at least 100 bytes per row, and the "filler"
@ -1433,6 +1434,16 @@ init(void)
} }
executeStatement(con, "commit"); executeStatement(con, "commit");
/* vacuum */
if (!is_no_vacuum)
{
fprintf(stderr, "vacuum...\n");
executeStatement(con, "vacuum analyze pgbench_branches");
executeStatement(con, "vacuum analyze pgbench_tellers");
executeStatement(con, "vacuum analyze pgbench_accounts");
executeStatement(con, "vacuum analyze pgbench_history");
}
/* /*
* create indexes * create indexes
*/ */
@ -1469,12 +1480,6 @@ init(void)
} }
} }
/* vacuum */
fprintf(stderr, "vacuum...");
executeStatement(con, "vacuum analyze pgbench_branches");
executeStatement(con, "vacuum analyze pgbench_tellers");
executeStatement(con, "vacuum analyze pgbench_accounts");
executeStatement(con, "vacuum analyze pgbench_history");
fprintf(stderr, "done.\n"); fprintf(stderr, "done.\n");
PQfinish(con); PQfinish(con);
@ -2139,7 +2144,7 @@ main(int argc, char **argv)
if (is_init_mode) if (is_init_mode)
{ {
init(); init(is_no_vacuum);
exit(0); exit(0);
} }

View File

@ -157,6 +157,15 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><option>-n</option></term>
<listitem>
<para>
Perform no vacuuming after initialization.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>-F</option> <replaceable>fillfactor</></term> <term><option>-F</option> <replaceable>fillfactor</></term>
<listitem> <listitem>