Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 46b2b7e

Browse files
committed
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.
1 parent b71258a commit 46b2b7e

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

contrib/pgbench/pgbench.c

+13-8
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ usage(void)
345345
" %s [OPTION]... [DBNAME]\n"
346346
"\nInitialization options:\n"
347347
" -i invokes initialization mode\n"
348+
" -n do not run VACUUM after initialization\n"
348349
" -F NUM fill factor\n"
349350
" -s NUM scaling factor\n"
350351
" --foreign-keys\n"
@@ -1282,7 +1283,7 @@ disconnect_all(CState *state, int length)
12821283

12831284
/* create tables and setup data */
12841285
static void
1285-
init(void)
1286+
init(bool is_no_vacuum)
12861287
{
12871288
/*
12881289
* Note: TPC-B requires at least 100 bytes per row, and the "filler"
@@ -1433,6 +1434,16 @@ init(void)
14331434
}
14341435
executeStatement(con, "commit");
14351436

1437+
/* vacuum */
1438+
if (!is_no_vacuum)
1439+
{
1440+
fprintf(stderr, "vacuum...\n");
1441+
executeStatement(con, "vacuum analyze pgbench_branches");
1442+
executeStatement(con, "vacuum analyze pgbench_tellers");
1443+
executeStatement(con, "vacuum analyze pgbench_accounts");
1444+
executeStatement(con, "vacuum analyze pgbench_history");
1445+
}
1446+
14361447
/*
14371448
* create indexes
14381449
*/
@@ -1469,12 +1480,6 @@ init(void)
14691480
}
14701481
}
14711482

1472-
/* vacuum */
1473-
fprintf(stderr, "vacuum...");
1474-
executeStatement(con, "vacuum analyze pgbench_branches");
1475-
executeStatement(con, "vacuum analyze pgbench_tellers");
1476-
executeStatement(con, "vacuum analyze pgbench_accounts");
1477-
executeStatement(con, "vacuum analyze pgbench_history");
14781483

14791484
fprintf(stderr, "done.\n");
14801485
PQfinish(con);
@@ -2139,7 +2144,7 @@ main(int argc, char **argv)
21392144

21402145
if (is_init_mode)
21412146
{
2142-
init();
2147+
init(is_no_vacuum);
21432148
exit(0);
21442149
}
21452150

doc/src/sgml/pgbench.sgml

+9
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,15 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
157157
</listitem>
158158
</varlistentry>
159159

160+
<varlistentry>
161+
<term><option>-n</option></term>
162+
<listitem>
163+
<para>
164+
Perform no vacuuming after initialization.
165+
</para>
166+
</listitem>
167+
</varlistentry>
168+
160169
<varlistentry>
161170
<term><option>-F</option> <replaceable>fillfactor</></term>
162171
<listitem>

0 commit comments

Comments
 (0)