From 46b2b7e0ff06498d51ebf08871c73e5b5e0aa050 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 23 Jul 2012 14:38:34 -0400 Subject: [PATCH] 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. --- contrib/pgbench/pgbench.c | 21 +++++++++++++-------- doc/src/sgml/pgbench.sgml | 9 +++++++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index a744f5fedb..00cab73f90 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -345,6 +345,7 @@ usage(void) " %s [OPTION]... [DBNAME]\n" "\nInitialization options:\n" " -i invokes initialization mode\n" + " -n do not run VACUUM after initialization\n" " -F NUM fill factor\n" " -s NUM scaling factor\n" " --foreign-keys\n" @@ -1282,7 +1283,7 @@ disconnect_all(CState *state, int length) /* create tables and setup data */ static void -init(void) +init(bool is_no_vacuum) { /* * Note: TPC-B requires at least 100 bytes per row, and the "filler" @@ -1433,6 +1434,16 @@ init(void) } 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 */ @@ -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"); PQfinish(con); @@ -2139,7 +2144,7 @@ main(int argc, char **argv) if (is_init_mode) { - init(); + init(is_no_vacuum); exit(0); } diff --git a/doc/src/sgml/pgbench.sgml b/doc/src/sgml/pgbench.sgml index 5ce66a6ac0..437fceab2e 100644 --- a/doc/src/sgml/pgbench.sgml +++ b/doc/src/sgml/pgbench.sgml @@ -157,6 +157,15 @@ pgbench options dbname + + + + + Perform no vacuuming after initialization. + + + + fillfactor