关闭

pgbench内置脚本

标签: 脚本测试工具
1752人阅读 评论(0) 收藏 举报
分类:

pgbench测试脚本如下

默认

static char *tpc_b = {
 "\\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"
 "\\setrandom delta -5000 5000\n"
 "BEGIN;\n"
 "UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\n"
 "SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n"
 "UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;\n"
 "UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;\n"
 "INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n"
 "END;\n"
};

/* -N case */
static char *simple_update = {
 "\\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"
 "\\setrandom delta -5000 5000\n"
 "BEGIN;\n"
 "UPDATE pgbench_accounts SET abalance = abalance + :delta WHERE aid = :aid;\n"
 "SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n"
 "INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);\n"
 "END;\n"
};

/* -S case */
static char *select_only = {
 "\\set naccounts 100000 * :scale\n"
 "\\setrandom aid 1 :naccounts\n"
 "SELECT abalance FROM pgbench_accounts WHERE aid = :aid;\n"
};

这些在源码文件夹的pgbench.c中可以看到。我们也可以自己写脚本文件,然后在运行pgbench的时候加参数-f指定脚本。

由此可见,其实pgbench的测试脚本还是很简单的,也有许多局限性。以后我们还会介绍另一个工具——pgbench-tool。它在一定程度上对pgbench进行了完善,虽然他也是调用pgbench。

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料