最新文章专题视频专题问答1问答10问答100问答1000问答2000关键字专题1关键字专题50关键字专题500关键字专题1500TAG最新视频文章推荐1 推荐3 推荐5 推荐7 推荐9 推荐11 推荐13 推荐15 推荐17 推荐19 推荐21 推荐23 推荐25 推荐27 推荐29 推荐31 推荐33 推荐35 推荐37视频文章20视频文章30视频文章40视频文章50视频文章60 视频文章70视频文章80视频文章90视频文章100视频文章120视频文章140 视频2关键字专题关键字专题tag2tag3文章专题文章专题2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章专题3
当前位置: 首页 - 科技 - 知识百科 - 正文

PostgreSQL数据库压力测试工具pgbench简单应用

来源:动视网 责编:小采 时间:2020-11-09 11:23:45
文档

PostgreSQL数据库压力测试工具pgbench简单应用

PostgreSQL数据库压力测试工具pgbench简单应用:PostgreSQL数据库提供了一款轻量级的压力测试工具叫pgbench,其实就是一个编译好后的扩展性的可执行文件。介绍如下。 环境: Cen PostgreSQL数据库提供了一款轻量级的压力测试工具叫pgbench,其实就是一个编译好后的扩展性的可执行文件。介绍如下。 环境:
推荐度:
导读PostgreSQL数据库压力测试工具pgbench简单应用:PostgreSQL数据库提供了一款轻量级的压力测试工具叫pgbench,其实就是一个编译好后的扩展性的可执行文件。介绍如下。 环境: Cen PostgreSQL数据库提供了一款轻量级的压力测试工具叫pgbench,其实就是一个编译好后的扩展性的可执行文件。介绍如下。 环境:


PostgreSQL数据库提供了一款轻量级的压力测试工具叫pgbench,其实就是一个编译好后的扩展性的可执行文件。介绍如下。 环境: Cen

PostgreSQL数据库提供了一款轻量级的压力测试工具叫pgbench,其实就是一个编译好后的扩展性的可执行文件。介绍如下。
环境:
CentOS 5.7(final)
PG:9.1.2
Vmware 8.0
数据库参数: max_connection=100 ,其他略,默认

1.安装
进入源码安装包,编译,安装 [postgres@localhost ~]$ cd postgresql-9.1.2/contrib/pgbench/ [postgres@localhost pgbench]$ ll total 164 -rw-r--r--. 1 postgres postgres 538 Dec 1 2011 Makefile -rwxrwxr-x. 1 postgres postgres 50203 Apr 26 23:50 pgbench -rw-r--r--. 1 postgres postgres 61154 Dec 1 2011 pgbench.c -rw-rw-r--. 1 postgres postgres 47920 Apr 26 23:50 pgbench.o [postgres@localhost pgbench]$make all [postgres@localhost pgbench]$make install安装完毕以后可以在bin文件夹下看到新生成的pgbench文件 [postgres@localhost bin]$ ll $PGHOME/bin pgbench -rwxr-xr-x. 1 postgres postgres 50203 Jul 8 20:28 pgbench2.参数介绍 [postgres@localhost bin]$ pgbench --help pgbench is a benchmarking tool for PostgreSQL. Usage: pgbench [OPTIONS]... [DBNAME] Initialization options: -i invokes initialization mode -F NUM fill factor -s NUM scaling factor Benchmarking options: -c NUM number of concurrent database clients (default: 1) -C establish new connection for each transaction -D VARNAME=VALUE define variable for use by custom script -f FILENAME read transaction script from FILENAME -j NUM number of threads (default: 1) -l write transaction times to log file -M {simple|extended|prepared} protocol for submitting queries to server (default: simple) -n do not run VACUUM before tests -N do not update tables "pgbench_tellers" and "pgbench_branches" -r report average latency per command -s NUM report this scale factor in output -S perform SELECT-only transactions -t NUM number of transactions each client runs (default: 10) -T NUM duration of benchmark test in seconds -v vacuum all four standard tables before tests Common options: -d print debugging output -h HOSTNAME database server host or socket directory -p PORT database server port number -U USERNAME connect as specified database user --help show this help, then exit --version output version information, then exit Report bugs to .3.初始化测试数据 [postgres@localhost ~]$ pgbench -i pgbench creating tables... 10000 tuples done. 20000 tuples done. 30000 tuples done. 40000 tuples done. 50000 tuples done. 60000 tuples done. 70000 tuples done. 80000 tuples done. 90000 tuples done. 100000 tuples done. set primary key... NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pgbench_branches_pkey" for table "pgbench_branches" NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pgbench_tellers_pkey" for table "pgbench_tellers" NOTICE: ALTER TABLE / ADD PRIMARY KEY will create implicit index "pgbench_accounts_pkey" for table "pgbench_accounts" vacuum...done. [postgres@localhost ~]$ psql -d pgbench psql (9.1.2) Type "help" for help. pgbench=# select count(1) from pgbench_accounts; count -------- 100000 (1 row) pgbench=# select count(1) from pgbench_branches; count ------- 1 (1 row) pgbench=# select count(1) from pgbench_history; count ------- 0 (1 row) pgbench=# select count(1) from pgbench_tellers; count ------- 10 (1 row) pgbench=# \d+ pgbench_accounts Table "public.pgbench_accounts" Column | Type | Modifiers | Storage | Description ----------+---------------+-----------+----------+------------- aid | integer | not null | plain | bid | integer | | plain | abalance | integer | | plain | filler | character(84) | | extended | Indexes: "pgbench_accounts_pkey" PRIMARY KEY, btree (aid) Has OIDs: no Options: fillfactor=100 pgbench=# \d+ pgbench_branches Table "public.pgbench_branches" Column | Type | Modifiers | Storage | Description ----------+---------------+-----------+----------+------------- bid | integer | not null | plain | bbalance | integer | | plain | filler | character(88) | | extended | Indexes: "pgbench_branches_pkey" PRIMARY KEY, btree (bid) Has OIDs: no Options: fillfactor=100 pgbench=# \d+ pgbench_history Table "public.pgbench_history" Column | Type | Modifiers | Storage | Description --------+-----------------------------+-----------+----------+------------- tid | integer | | plain | bid | integer | | plain | aid | integer | | plain | delta | integer | | plain | mtime | timestamp without time zone | | plain | filler | character(22) | | extended | Has OIDs: no pgbench=# \d+ pgbench_tellers Table "public.pgbench_tellers" Column | Type | Modifiers | Storage | Description ----------+---------------+-----------+----------+------------- tid | integer | not null | plain | bid | integer | | plain | tbalance | integer | | plain | filler | character(84) | | extended | Indexes: "pgbench_tellers_pkey" PRIMARY KEY, btree (tid) Has OIDs: no Options: fillfactor=100说明:
a.这里使用的是默认的参数值,带-s 参数时可指定测试数据的数据量,-f可以指定测试的脚本,这里用的是默认脚本
b.不要在生产的库上做,新建一个测试库,当生产上有同名的测试表时将被重置

文档

PostgreSQL数据库压力测试工具pgbench简单应用

PostgreSQL数据库压力测试工具pgbench简单应用:PostgreSQL数据库提供了一款轻量级的压力测试工具叫pgbench,其实就是一个编译好后的扩展性的可执行文件。介绍如下。 环境: Cen PostgreSQL数据库提供了一款轻量级的压力测试工具叫pgbench,其实就是一个编译好后的扩展性的可执行文件。介绍如下。 环境:
推荐度:
  • 热门焦点

最新推荐

猜你喜欢

热门推荐

专题
Top