diff --git a/contrib/pgbench/README.pgbench b/contrib/pgbench/README.pgbench index 9ad30b317db1b656d1ba1fb099e8643ba3353a75..c96f0851a48f5a3193a41d34b165083814c37256 100644 --- a/contrib/pgbench/README.pgbench +++ b/contrib/pgbench/README.pgbench @@ -184,7 +184,7 @@ o -f option example: - \set ntellers 10 * :tps + \set ntellers 10 * :scale \setrandom name min max @@ -206,9 +206,9 @@ o -f option Example, TPC-B like benchmark can be defined as follows(scaling factor = 1): -\set nbranches :tps -\set ntellers 10 * :tps -\set naccounts 100000 * :tps +\set nbranches :scale +\set ntellers 10 * :scale +\set naccounts 100000 * :scale \setrandom aid 1 :naccounts \setrandom bid 1 :nbranches \setrandom tid 1 :ntellers @@ -235,6 +235,12 @@ Basically it is same as BSD license. See pgbench.c for more details. o History +2006/09/14 + * change "tps" to "scale" to avoid confusion + + * fix bug with handling default scaling factor in the default + scenarios + 2006/07/26 * New features contributed by Tomoaki Sato. diff --git a/contrib/pgbench/README.pgbench_jis b/contrib/pgbench/README.pgbench_jis index 37bd4d9280a14742e0bc650201226e450e357da9..0faa30de68b2ee2f17c594ba002dd8c352eac5bc 100644 --- a/contrib/pgbench/README.pgbench_jis +++ b/contrib/pgbench/README.pgbench_jis @@ -73,7 +73,7 @@ pgbench にはいろいろなオプションがあります. 大きさが 10万 x [スケーリングファクター]になります. デフォルトのスケーリングファクターは 1 です. -f オプションで指定したファイルからスケーリングファク - ターを参照するには tps という変数名を使用します. + ターを参照するには scale という変数名を使用します. -D varname=value @@ -223,7 +223,7 @@ pgbench では,以下のシーケンスを全部完了して1トランザクションと数えて���変数に演算の結果を設定するには,\set メタコマンドを使用して以 下のように記述します. - \set ntellers 10 * :tps + \set ntellers 10 * :tp これは,変数 ntellers にスケーリングファクター (-s オプション で指定した) を 10 倍した結果を設定します. @@ -253,9 +253,9 @@ SELECT abalance FROM accounts WHERE aid = :aid ザクションの内容をファイルに記述し,-f オプションによってそのファイル を指定して pgbench を実行します. -\set nbranches :tps -\set ntellers 10 * :tps -\set naccounts 100000 * :tps +\set nbranches :scale +\set ntellers 10 * :scale +\set naccounts 100000 * :scale \setrandom aid 1 :naccounts \setrandom bid 1 :nbranches \setrandom tid 1 :ntellers @@ -285,6 +285,10 @@ pgbench は石井 達夫によって書かれました.ライセンス条件は pgbench.c ■改定履歴 +2006/09/13 + * 変数tpsは紛らわしいのでscaleに変更.デフォルトシナリオの時に, + デフォルトのスケーリングファクタをbranchesから取ってこないバグを修正. + 2006/07/26 * 佐藤さんのパッチを適用.以下の機能追加.PostgreSQL 8.2に取り 込まれます. diff --git a/contrib/pgbench/pgbench.c b/contrib/pgbench/pgbench.c index 416f3c2e3241534e9b12d7b6b69a078441cfaa13..63c75878b4bbb5fa2a8ef1fda47d0aa27a823c3c 100644 --- a/contrib/pgbench/pgbench.c +++ b/contrib/pgbench/pgbench.c @@ -1,5 +1,5 @@ /* - * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.53 2006/08/15 13:05:30 ishii Exp $ + * $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.54 2006/09/13 00:39:19 ishii Exp $ * * pgbench: a simple benchmark program for PostgreSQL * written by Tatsuo Ishii @@ -58,10 +58,10 @@ int nclients = 1; /* default number of simulated clients */ int nxacts = 10; /* default number of transactions per clients */ /* - * scaling factor. for example, tps = 10 will make 1000000 tuples of + * scaling factor. for example, scale = 10 will make 1000000 tuples of * accounts table. */ -int tps = 1; +int scale = 1; /* * end of configurable parameters @@ -134,9 +134,9 @@ int num_files; /* its number */ /* default scenario */ static char *tpc_b = { - "\\set nbranches :tps\n" - "\\set ntellers 10 * :tps\n" - "\\set naccounts 100000 * :tps\n" + "\\set nbranches :scale\n" + "\\set ntellers 10 * :scale\n" + "\\set naccounts 100000 * :scale\n" "\\setrandom aid 1 :naccounts\n" "\\setrandom bid 1 :nbranches\n" "\\setrandom tid 1 :ntellers\n" @@ -152,9 +152,9 @@ static char *tpc_b = { /* -N case */ static char *simple_update = { - "\\set nbranches :tps\n" - "\\set ntellers 10 * :tps\n" - "\\set naccounts 100000 * :tps\n" + "\\set nbranches :scale\n" + "\\set ntellers 10 * :scale\n" + "\\set naccounts 100000 * :scale\n" "\\setrandom aid 1 :naccounts\n" "\\setrandom bid 1 :nbranches\n" "\\setrandom tid 1 :ntellers\n" @@ -168,7 +168,7 @@ static char *simple_update = { /* -S case */ static char *select_only = { - "\\set naccounts 100000 * :tps\n" + "\\set naccounts 100000 * :scale\n" "\\setrandom aid 1 :naccounts\n" "SELECT abalance FROM accounts WHERE aid = :aid;\n" }; @@ -338,10 +338,13 @@ putVariable(CState * st, char *name, char *value) } else { - if ((value = strdup(value)) == NULL) + char *val; + + if ((val = strdup(value)) == NULL) return false; + free(var->value); - var->value = value; + var->value = val; } return true; @@ -755,7 +758,7 @@ init(void) } PQclear(res); - for (i = 0; i < nbranches * tps; i++) + for (i = 0; i < nbranches * scale; i++) { snprintf(sql, 256, "insert into branches(bid,bbalance) values(%d,0)", i + 1); res = PQexec(con, sql); @@ -767,7 +770,7 @@ init(void) PQclear(res); } - for (i = 0; i < ntellers * tps; i++) + for (i = 0; i < ntellers * scale; i++) { snprintf(sql, 256, "insert into tellers(tid,bid,tbalance) values (%d,%d,0)" ,i + 1, i / ntellers + 1); @@ -792,7 +795,7 @@ init(void) * occupy accounts table with some data */ fprintf(stderr, "creating tables...\n"); - for (i = 0; i < naccounts * tps; i++) + for (i = 0; i < naccounts * scale; i++) { int j = i + 1; @@ -1133,7 +1136,7 @@ printResults( s = "Custom query"; printf("transaction type: %s\n", s); - printf("scaling factor: %d\n", tps); + printf("scaling factor: %d\n", scale); printf("number of clients: %d\n", nclients); printf("number of transactions per client: %d\n", nxacts); printf("number of transactions actually processed: %d/%d\n", normal_xacts, nxacts * nclients); @@ -1175,6 +1178,8 @@ main(int argc, char **argv) PGresult *res; char *env; + char val[64]; + if ((env = getenv("PGHOST")) != NULL && *env != '\0') pghost = env; if ((env = getenv("PGPORT")) != NULL && *env != '\0') @@ -1248,10 +1253,10 @@ main(int argc, char **argv) is_connect = 1; break; case 's': - tps = atoi(optarg); - if (tps <= 0) + scale = atoi(optarg); + if (scale <= 0) { - fprintf(stderr, "invalid scaling factor: %d\n", tps); + fprintf(stderr, "invalid scaling factor: %d\n", scale); exit(1); } break; @@ -1323,12 +1328,10 @@ main(int argc, char **argv) remains = nclients; - if (getVariable(&state[0], "tps") == NULL) + if (getVariable(&state[0], "scale") == NULL) { - char val[64]; - - snprintf(val, sizeof(val), "%d", tps); - if (putVariable(&state[0], "tps", val) == false) + snprintf(val, sizeof(val), "%d", scale); + if (putVariable(&state[0], "scale", val) == false) { fprintf(stderr, "Couldn't allocate memory for variable\n"); exit(1); @@ -1405,13 +1408,20 @@ main(int argc, char **argv) fprintf(stderr, "%s", PQerrorMessage(con)); exit(1); } - tps = atoi(PQgetvalue(res, 0, 0)); - if (tps < 0) + scale = atoi(PQgetvalue(res, 0, 0)); + if (scale < 0) { - fprintf(stderr, "count(*) from branches invalid (%d)\n", tps); + fprintf(stderr, "count(*) from branches invalid (%d)\n", scale); exit(1); } PQclear(res); + + snprintf(val, sizeof(val), "%d", scale); + if (putVariable(&state[0], "scale", val) == false) + { + fprintf(stderr, "Couldn't allocate memory for variable\n"); + exit(1); + } } if (!is_no_vacuum)