Patches from Yutaka Tanida. Create primary key indexes after data
authorTatsuo Ishii
Wed, 26 Nov 2003 06:53:18 +0000 (06:53 +0000)
committerTatsuo Ishii
Wed, 26 Nov 2003 06:53:18 +0000 (06:53 +0000)
insertion to reduce initialization time.

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

index 855e6abc429dfaeaa896693c537cdb5d79cd96ac..5ac8bace3fe4e74987bef73a81fd581e9d3a2ef3 100644 (file)
@@ -1,4 +1,4 @@
-pgbench README     2002/07/20 Tatsuo Ishii ([email protected])
+pgbench README     2003/11/26 Tatsuo Ishii ([email protected])
 
 o What is pgbench?
 
@@ -164,6 +164,10 @@ Basically it is same as BSD license. See pgbench.c for more details.
 
 o History
 
+2003/11/26
+   * create indexes after data insertion to reduce time.
+     patch from Yutaka Tanida.
+
 2003/06/10
    * fix uninitialized memory bug
    * add support for PGHOST, PGPORT, PGUSER environment variables
index d7e261deca1b9b52840888b7cee36fc57c3e44e1..82a2f6a39bf4b30ce157c2b388f4cd456e00adcd 100644 (file)
@@ -1,4 +1,4 @@
-pgbench README     2002/07/20 Tatsuo Ishii ([email protected])
+pgbench README     2003/11/26 Tatsuo Ishii ([email protected])
 
 \e$B"#\e(Bpgbench \e$B$H$O!)\e(B
 
@@ -184,6 +184,11 @@ pgbench \e$B$O@P0f\e(B \e$BC#IW$K$h$C$F=q$+$l$^$7$?!%%i%$%;%s%9>r7o$O\e(B pgbench.c
 
 \e$B"#2~DjMzNr\e(B
 
+2003/11/26
+   * \e$BC+ED$5$s$N%Q%C%A$rE,MQ!%\e(Bpgbench -i\e$B$N:]$K!$8e$+$i\e(B
+     \e$B$9$k$h$&$K$7$?!%$3$l$K$h$C$F=i4|2=$N\e(B
+     \e$B$k\e(B(\e$B$O$:\e(B)\e$B!%\e(B
+
 2003/06/10
    * \e$B%a%b%j$,=i4|2=$5$l$F$$$J$$%P%0$r=$@5\e(B
    * \e$B4D6-JQ?t\e(BPGHOST, PGPORT, PGUSER\e$B$rG'<1$9$k$h$&$K$7$?!%\e(B
index 94e79ba021f2c15090e0cb3abbf0bd38ed151af1..8d817d9c6e22e33aaf0675facf35da7f10789524 100644 (file)
@@ -1,10 +1,10 @@
 /*
- * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.27 2003/09/27 19:15:34 wieck Exp $
+ * $Header: /cvsroot/pgsql/contrib/pgbench/pgbench.c,v 1.28 2003/11/26 06:53:18 ishii Exp $
  *
  * pgbench: a simple TPC-B like benchmark program for PostgreSQL
  * written by Tatsuo Ishii
  *
- * Copyright (c) 2000-2002 Tatsuo Ishii
+ * Copyright (c) 2000-2003 Tatsuo Ishii
  *
  * Permission to use, copy, modify, and distribute this software and
  * its documentation for any purpose and without fee is hereby
@@ -482,13 +482,19 @@ init(void)
    PGresult   *res;
    static char *DDLs[] = {
        "drop table branches",
-       "create table branches(bid int, primary key(bid),bbalance int,filler char(88))",
+       "create table branches(bid int not null,bbalance int,filler char(88))",
        "drop table tellers",
-       "create table tellers(tid int, primary key(tid),bid int,tbalance int,filler char(84))",
+       "create table tellers(tid int not null,bid int,tbalance int,filler char(84))",
        "drop table accounts",
-       "create table accounts(aid int,primary key(aid),bid int,abalance int,filler char(84))",
+       "create table accounts(aid int not null,bid int,abalance int,filler char(84))",
        "drop table history",
    "create table history(tid int,bid int,aid int,delta int,mtime timestamp,filler char(22))"};
+   static char *DDLAFTERs[] = {
+       "alter table branches add primary key (bid)",
+       "alter table tellers add primary key (tid)",
+       "alter table accounts add primary key (aid)"};
+
+
    char        sql[256];
 
    int         i;
@@ -608,6 +614,17 @@ init(void)
 #endif   /* NOT_USED */
        }
    }
+   fprintf(stderr, "set primary key...\n");
+   for (i = 0; i < (sizeof(DDLAFTERs) / sizeof(char *)); i++)
+   {
+       res = PQexec(con, DDLAFTERs[i]);
+       if (strncmp(DDLs[i], "drop", 4) && PQresultStatus(res) != PGRES_COMMAND_OK)
+       {
+           fprintf(stderr, "%s", PQerrorMessage(con));
+           exit(1);
+       }
+       PQclear(res);
+   }
 
    /* vacuum */
    fprintf(stderr, "vacuum...");