Add -F option to set fillfactor for tellers, accounts and branches.
authorTatsuo Ishii
Sun, 8 Apr 2007 01:15:07 +0000 (01:15 +0000)
committerTatsuo Ishii
Sun, 8 Apr 2007 01:15:07 +0000 (01:15 +0000)
Patch contributed by Pavan Deolasee. Along with Japanese doc
modification by Tatsuo Ishii.

contrib/pgbench/README.pgbench
contrib/pgbench/README.pgbench_jis
contrib/pgbench/pgbench.c

index ef040c094d7663c2adfea9020897eb802319cab6..599dc3b6c541552579ff524b2102b5548c1e5e97 100644 (file)
@@ -1,4 +1,4 @@
-$PostgreSQL: pgsql/contrib/pgbench/README.pgbench,v 1.17 2007/04/06 09:16:15 ishii Exp $
+$PostgreSQL: pgsql/contrib/pgbench/README.pgbench,v 1.18 2007/04/08 01:15:07 ishii Exp $
 
 pgbench README
 
@@ -57,8 +57,9 @@ o How to use pgbench?
    accounts    100000
    history     0
 
-   You can increase the number of tuples by using -s option. See
-   below.
+   You can increase the number of tuples by using -s option. branches,
+   tellers and accounts tables are created with a fillfactor which is
+   set using -F option. See below.
 
   (2) Run the benchmark test
 
@@ -162,6 +163,12 @@ o options
        0 201 2513 0 1175850569 608
        0 202 2038 0 1175850569 2663
 
+   -F fillfactor
+
+       Create tables(accounts, tellers and branches) with the given
+       fillfactor. Default is 100.  This should be used with -i
+       (initialize) option.
+       
    -d
        debug option.
 
index e06587a879145eb7cddd24020734c99ef77d557a..9a4d809aa99ea4f4b852d381689f5ef91a7005d6 100644 (file)
@@ -1,4 +1,4 @@
-$PostgreSQL: pgsql/contrib/pgbench/README.pgbench_jis,v 1.18 2007/04/06 09:16:16 ishii Exp $
+$PostgreSQL: pgsql/contrib/pgbench/README.pgbench_jis,v 1.19 2007/04/08 01:15:07 ishii Exp $
 
 pgbench README
 
@@ -155,6 +155,11 @@ pgbench \e$B$K$O$$$m$$$m$J%*%W%7%g%s$,$"$j$^$9!%\e(B
        0 201 2513 0 1175850569 608
        0 202 2038 0 1175850569 2663
 
+-F \e$B%U%#%k%U%!%/%?!<\e(B
+       accounts, tellers, bracnhes\e$B%F!<%V%k$r:n@.$9$k:]$K;XDj$5$l$?%U%#\e(B
+       \e$B%k%U%!%/%?!<$r;HMQ$7$^$9!%%U%#%k%U%!%/%?!<$N%G%U%)%k%H$O\e(B100\e$B$G\e(B
+       \e$B$9!%$3$N%*%W%7%g%s$O\e(B -i \e$B%*%W%7%g%s$HF1;~$K;HMQ$7$^$9!%\e(B
+
 -d     \e$B%G%P%C%0%*%W%7%g%s!%MM!9$J>pJs$,I=<($5$l$^$9!%\e(B
 
 \e$B"#%G!<%?%Y!<%9$N=i4|2=\e(B
index 2ffd24b25b907d2242e9331a18b8f070724fcd8d..9bab53c940b170d98ea2f56f8a25203ef3d2d0d3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.64 2007/04/06 09:16:16 ishii Exp $
+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.65 2007/04/08 01:15:07 ishii Exp $
  *
  * pgbench: a simple benchmark program for PostgreSQL
  * written by Tatsuo Ishii
@@ -64,6 +64,12 @@ int          nxacts = 10;        /* default number of transactions per clients */
  */
 int            scale = 1;
 
+/*
+ * fillfactor. for example, fillfactor = 90 will use only 90 percent
+ * space during inserts and leave 10 percent free.
+ */
+int            fillfactor = 100;
+
 /*
  * end of configurable parameters
  *********************************************************************/
@@ -178,7 +184,7 @@ static void
 usage(void)
 {
    fprintf(stderr, "usage: pgbench [-h hostname][-p port][-c nclients][-t ntransactions][-s scaling_factor][-D varname=value][-n][-C][-v][-S][-N][-f filename][-l][-U login][-P password][-d][dbname]\n");
-   fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-U login][-P password][-d][dbname]\n");
+   fprintf(stderr, "(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor] [-F fillfactor] [-U login][-P password][-d][dbname]\n");
 }
 
 /* random number generator */
@@ -730,11 +736,11 @@ init(void)
    PGresult   *res;
    static char *DDLs[] = {
        "drop table if exists branches",
-       "create table branches(bid int not null,bbalance int,filler char(88))",
+       "create table branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=%d)",
        "drop table if exists tellers",
-       "create table tellers(tid int not null,bid int,tbalance int,filler char(84))",
+       "create table tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=%d)",
        "drop table if exists accounts",
-       "create table accounts(aid int not null,bid int,abalance int,filler char(84))",
+       "create table accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=%d)",
        "drop table if exists history",
        "create table history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22))"};
    static char *DDLAFTERs[] = {
@@ -751,7 +757,22 @@ init(void)
        exit(1);
 
    for (i = 0; i < lengthof(DDLs); i++)
-       executeStatement(con, DDLs[i]);
+   {
+       /*
+        * set fillfactor for branches, tellers and accounts tables
+        */
+       if ((strstr(DDLs[i], "create table branches") == DDLs[i]) ||
+           (strstr(DDLs[i], "create table tellers") == DDLs[i]) ||
+           (strstr(DDLs[i], "create table accounts") == DDLs[i]))
+       {
+           char ddl_stmt[128];
+           snprintf(ddl_stmt, 128, DDLs[i], fillfactor);
+           executeStatement(con, ddl_stmt);
+           continue;
+       }
+       else
+           executeStatement(con, DDLs[i]);
+   }
 
    executeStatement(con, "begin");
 
@@ -1153,7 +1174,7 @@ main(int argc, char **argv)
 
    memset(state, 0, sizeof(*state));
 
-   while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CNSlf:D:")) != -1)
+   while ((c = getopt(argc, argv, "ih:nvp:dc:t:s:U:P:CNSlf:D:F:")) != -1)
    {
        switch (c)
        {
@@ -1258,6 +1279,14 @@ main(int argc, char **argv)
                    }
                }
                break;
+           case 'F':
+               fillfactor = atoi(optarg);
+               if ((fillfactor < 10) || (fillfactor > 100))
+               {
+                   fprintf(stderr, "invalid fillfactor: %d\n", fillfactor);
+                   exit(1);
+               }
+               break;
            default:
                usage();
                exit(1);