]> granicus.if.org Git - postgresql/commitdiff
Make pgbench vacuum before building indexes.
authorRobert Haas <rhaas@postgresql.org>
Mon, 23 Jul 2012 18:38:34 +0000 (14:38 -0400)
committerRobert Haas <rhaas@postgresql.org>
Mon, 23 Jul 2012 18:42:35 +0000 (14:42 -0400)
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
doc/src/sgml/pgbench.sgml

index a744f5fedb570e0b377a9c70ac856aff5bad980c..00cab73f90957c7427a903cb37ea2dc3be200069 100644 (file)
@@ -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);
        }
 
index 5ce66a6ac04a52b09a6a5fe7d1dde24cbd0d5bfa..437fceab2e482e9821e09be3e8e988e18c2289cd 100644 (file)
@@ -157,6 +157,15 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>-n</option></term>
+      <listitem>
+       <para>
+        Perform no vacuuming after initialization.
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>-F</option> <replaceable>fillfactor</></term>
       <listitem>