Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit46d9c2e

Browse files
committed
Change the delta val from 0 and 10000 to -5000 and 5000 per recent
discussion in hackers list. Also enhance predefined benchmarkscenarios to reflect the scaling factor parameter flexibly.
1 parent51175d1 commit46d9c2e

File tree

1 file changed

+25
-30
lines changed

1 file changed

+25
-30
lines changed

‎contrib/pgbench/pgbench.c

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.50 2006/07/26 07:24:50 ishii Exp $
2+
* $PostgreSQL: pgsql/contrib/pgbench/pgbench.c,v 1.51 2006/07/28 22:58:26 ishii Exp $
33
*
44
* pgbench: a simple benchmark program for PostgreSQL
55
* written by Tatsuo Ishii
@@ -134,10 +134,13 @@ intnum_files;/* its number */
134134

135135
/* default scenario */
136136
staticchar*tpc_b= {
137-
"\\setrandom aid 1 100000\n"
138-
"\\setrandom bid 1 1\n"
139-
"\\setrandom tid 1 10\n"
140-
"\\setrandom delta 1 10000\n"
137+
"\\set nbranches :tps\n"
138+
"\\set ntellers 10 * :tps\n"
139+
"\\set naccounts 100000 * :tps\n"
140+
"\\setrandom aid 1 :naccounts\n"
141+
"\\setrandom bid 1 :nbranches\n"
142+
"\\setrandom tid 1 :ntellers\n"
143+
"\\setrandom delta -5000 5000\n"
141144
"BEGIN;\n"
142145
"UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n"
143146
"SELECT abalance FROM accounts WHERE aid = :aid;\n"
@@ -149,10 +152,13 @@ static char *tpc_b = {
149152

150153
/* -N case */
151154
staticchar*simple_update= {
152-
"\\setrandom aid 1 100000\n"
153-
"\\setrandom bid 1 1\n"
154-
"\\setrandom tid 1 10\n"
155-
"\\setrandom delta 1 10000\n"
155+
"\\set nbranches :tps\n"
156+
"\\set ntellers 10 * :tps\n"
157+
"\\set naccounts 100000 * :tps\n"
158+
"\\setrandom aid 1 :naccounts\n"
159+
"\\setrandom bid 1 :nbranches\n"
160+
"\\setrandom tid 1 :ntellers\n"
161+
"\\setrandom delta -5000 5000\n"
156162
"BEGIN;\n"
157163
"UPDATE accounts SET abalance = abalance + :delta WHERE aid = :aid;\n"
158164
"SELECT abalance FROM accounts WHERE aid = :aid;\n"
@@ -162,7 +168,8 @@ static char *simple_update = {
162168

163169
/* -S case */
164170
staticchar*select_only= {
165-
"\\setrandom aid 1 100000\n"
171+
"\\set naccounts 100000 * :tps\n"
172+
"\\setrandom aid 1 :naccounts\n"
166173
"SELECT abalance FROM accounts WHERE aid = :aid;\n"
167174
};
168175

@@ -570,12 +577,14 @@ doCustom(CState * state, int n, int debug)
570577
else
571578
min=atoi(argv[2]);
572579

580+
#ifdefNOT_USED
573581
if (min<0)
574582
{
575583
fprintf(stderr,"%s: invalid minimum number %d\n",argv[0],min);
576584
st->ecnt++;
577585
return;
578586
}
587+
#endif
579588

580589
if (*argv[3]==':')
581590
{
@@ -597,6 +606,9 @@ doCustom(CState * state, int n, int debug)
597606
return;
598607
}
599608

609+
#ifdefDEBUG
610+
printf("min: %d max: %d random: %d\n",min,max,getrand(min,max));
611+
#endif
600612
snprintf(res,sizeof(res),"%d",getrand(min,max));
601613

602614
if (putVariable(st,argv[1],res)== false)
@@ -1477,38 +1489,21 @@ main(int argc, char **argv)
14771489
/* process bultin SQL scripts */
14781490
switch (ttype)
14791491
{
1480-
charbuf[128];
1481-
14821492
case0:
14831493
sql_files[0]=process_builtin(tpc_b);
1484-
snprintf(buf,sizeof(buf),"%d",100000*tps);
1485-
sql_files[0][0]->argv[3]=strdup(buf);
1486-
snprintf(buf,sizeof(buf),"%d",1*tps);
1487-
sql_files[0][1]->argv[3]=strdup(buf);
1488-
snprintf(buf,sizeof(buf),"%d",10*tps);
1489-
sql_files[0][2]->argv[3]=strdup(buf);
1490-
snprintf(buf,sizeof(buf),"%d",10000*tps);
1491-
sql_files[0][3]->argv[3]=strdup(buf);
14921494
num_files=1;
14931495
break;
1496+
14941497
case1:
14951498
sql_files[0]=process_builtin(select_only);
1496-
snprintf(buf,sizeof(buf),"%d",100000*tps);
1497-
sql_files[0][0]->argv[3]=strdup(buf);
14981499
num_files=1;
14991500
break;
1501+
15001502
case2:
15011503
sql_files[0]=process_builtin(simple_update);
1502-
snprintf(buf,sizeof(buf),"%d",100000*tps);
1503-
sql_files[0][0]->argv[3]=strdup(buf);
1504-
snprintf(buf,sizeof(buf),"%d",1*tps);
1505-
sql_files[0][1]->argv[3]=strdup(buf);
1506-
snprintf(buf,sizeof(buf),"%d",10*tps);
1507-
sql_files[0][2]->argv[3]=strdup(buf);
1508-
snprintf(buf,sizeof(buf),"%d",10000*tps);
1509-
sql_files[0][3]->argv[3]=strdup(buf);
15101504
num_files=1;
15111505
break;
1506+
15121507
default:
15131508
break;
15141509
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp