diff --git a/doc/src/sgml/ref/pgbench.sgml b/doc/src/sgml/ref/pgbench.sgml index 03e1212..ec63992 100644 --- a/doc/src/sgml/ref/pgbench.sgml +++ b/doc/src/sgml/ref/pgbench.sgml @@ -248,6 +248,15 @@ pgbench options dbname + + + + + Create no primary keys after initialization. + + + + diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 4d364a1..c475d43 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -477,6 +477,7 @@ usage(void) " -i, --initialize invokes initialization mode\n" " -F, --fillfactor=NUM set fill factor\n" " -n, --no-vacuum do not run VACUUM after initialization\n" + " -I, --no-primary-keys skip building primary keys after initialization\n" " -q, --quiet quiet logging (one message each 5 seconds)\n" " -s, --scale=NUM scaling factor\n" " --foreign-keys create foreign key constraints between tables\n" @@ -2568,7 +2569,7 @@ disconnect_all(CState *state, int length) /* create tables and setup data */ static void -init(bool is_no_vacuum) +init(bool is_no_vacuum, bool is_no_pkeys) { /* * The scale factor at/beyond which 32-bit integers are insufficient for @@ -2806,25 +2807,28 @@ init(bool is_no_vacuum) /* * create indexes */ - fprintf(stderr, "set primary keys...\n"); - for (i = 0; i < lengthof(DDLINDEXes); i++) + if (!is_no_pkeys) { - char buffer[256]; + fprintf(stderr, "set primary keys...\n"); + for (i = 0; i < lengthof(DDLINDEXes); i++) + { + char buffer[256]; - strlcpy(buffer, DDLINDEXes[i], sizeof(buffer)); + strlcpy(buffer, DDLINDEXes[i], sizeof(buffer)); - if (index_tablespace != NULL) - { - char *escape_tablespace; + if (index_tablespace != NULL) + { + char *escape_tablespace; - escape_tablespace = PQescapeIdentifier(con, index_tablespace, - strlen(index_tablespace)); - snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), - " using index tablespace %s", escape_tablespace); - PQfreemem(escape_tablespace); - } + escape_tablespace = PQescapeIdentifier(con, index_tablespace, + strlen(index_tablespace)); + snprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), + " using index tablespace %s", escape_tablespace); + PQfreemem(escape_tablespace); + } - executeStatement(con, buffer); + executeStatement(con, buffer); + } } /* @@ -3623,6 +3627,7 @@ main(int argc, char **argv) {"log", no_argument, NULL, 'l'}, {"latency-limit", required_argument, NULL, 'L'}, {"no-vacuum", no_argument, NULL, 'n'}, + {"no-primary-keys", no_argument, NULL, 'I'}, {"port", required_argument, NULL, 'p'}, {"progress", required_argument, NULL, 'P'}, {"protocol", required_argument, NULL, 'M'}, @@ -3651,6 +3656,7 @@ main(int argc, char **argv) int c; int is_init_mode = 0; /* initialize mode? */ int is_no_vacuum = 0; /* no vacuum at all before testing? */ + int is_no_pkeys = 0; /* no primary keys build at after initialization */ int do_vacuum_accounts = 0; /* do vacuum accounts before testing? */ int optindex; bool scale_given = false; @@ -3711,7 +3717,7 @@ main(int argc, char **argv) state = (CState *) pg_malloc(sizeof(CState)); memset(state, 0, sizeof(CState)); - while ((c = getopt_long(argc, argv, "ih:nvp:dqb:SNc:j:Crs:t:T:U:lf:D:F:M:P:R:L:", long_options, &optindex)) != -1) + while ((c = getopt_long(argc, argv, "iIh:nvp:dqb:SNc:j:Crs:t:T:U:lf:D:F:M:P:R:L:", long_options, &optindex)) != -1) { char *script; @@ -3862,6 +3868,9 @@ main(int argc, char **argv) benchmarking_option_set = true; internal_script_used = true; break; + case 'I': + is_no_pkeys++; + break; case 'f': weight = parseScriptWeight(optarg, &script); process_file(script, weight); @@ -4052,7 +4061,7 @@ main(int argc, char **argv) exit(1); } - init(is_no_vacuum); + init(is_no_vacuum, is_no_pkeys); exit(0); } else