11/*
2- * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.64 2007/04/06 09:16:16 ishii Exp $
2+ * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.65 2007/04/08 01:15:07 ishii Exp $
33 *
44 * pgbench: a simple benchmark program for PostgreSQL
55 * written by Tatsuo Ishii
@@ -64,6 +64,12 @@ intnxacts = 10;/* default number of transactions per clients */
6464 */
6565int scale = 1 ;
6666
67+ /*
68+ * fillfactor. for example, fillfactor = 90 will use only 90 percent
69+ * space during inserts and leave 10 percent free.
70+ */
71+ int fillfactor = 100 ;
72+
6773/*
6874 * end of configurable parameters
6975 *********************************************************************/
@@ -178,7 +184,7 @@ static void
178184usage (void )
179185{
180186fprintf (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" );
181- fprintf (stderr ,"(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor][-U login][-P password][-d][dbname]\n" );
187+ fprintf (stderr ,"(initialize mode): pgbench -i [-h hostname][-p port][-s scaling_factor] [-F fillfactor] [-U login][-P password][-d][dbname]\n" );
182188}
183189
184190/* random number generator */
@@ -730,11 +736,11 @@ init(void)
730736PGresult * res ;
731737static char * DDLs []= {
732738"drop table if exists branches" ,
733- "create table branches(bid int not null,bbalance int,filler char(88))" ,
739+ "create table branches(bid int not null,bbalance int,filler char(88)) with (fillfactor=%d) " ,
734740"drop table if exists tellers" ,
735- "create table tellers(tid int not null,bid int,tbalance int,filler char(84))" ,
741+ "create table tellers(tid int not null,bid int,tbalance int,filler char(84)) with (fillfactor=%d) " ,
736742"drop table if exists accounts" ,
737- "create table accounts(aid int not null,bid int,abalance int,filler char(84))" ,
743+ "create table accounts(aid int not null,bid int,abalance int,filler char(84)) with (fillfactor=%d) " ,
738744"drop table if exists history" ,
739745"create table history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22))" };
740746static char * DDLAFTERs []= {
@@ -751,7 +757,22 @@ init(void)
751757exit (1 );
752758
753759for (i = 0 ;i < lengthof (DDLs );i ++ )
754- executeStatement (con ,DDLs [i ]);
760+ {
761+ /*
762+ * set fillfactor for branches, tellers and accounts tables
763+ */
764+ if ((strstr (DDLs [i ],"create table branches" )== DDLs [i ])||
765+ (strstr (DDLs [i ],"create table tellers" )== DDLs [i ])||
766+ (strstr (DDLs [i ],"create table accounts" )== DDLs [i ]))
767+ {
768+ char ddl_stmt [128 ];
769+ snprintf (ddl_stmt ,128 ,DDLs [i ],fillfactor );
770+ executeStatement (con ,ddl_stmt );
771+ continue ;
772+ }
773+ else
774+ executeStatement (con ,DDLs [i ]);
775+ }
755776
756777executeStatement (con ,"begin" );
757778
@@ -1153,7 +1174,7 @@ main(int argc, char **argv)
11531174
11541175memset (state ,0 ,sizeof (* state ));
11551176
1156- while ((c = getopt (argc ,argv ,"ih:nvp:dc:t:s:U:P:CNSlf:D:" ))!= -1 )
1177+ while ((c = getopt (argc ,argv ,"ih:nvp:dc:t:s:U:P:CNSlf:D:F: " ))!= -1 )
11571178{
11581179switch (c )
11591180{
@@ -1258,6 +1279,14 @@ main(int argc, char **argv)
12581279}
12591280}
12601281break ;
1282+ case 'F' :
1283+ fillfactor = atoi (optarg );
1284+ if ((fillfactor < 10 )|| (fillfactor > 100 ))
1285+ {
1286+ fprintf (stderr ,"invalid fillfactor: %d\n" ,fillfactor );
1287+ exit (1 );
1288+ }
1289+ break ;
12611290default :
12621291usage ();
12631292exit (1 );