pgbench

创建

create database bpx;
pgbench -i -s 1000 bpx

压测

create database bpx1;
pgbench -i -s 100 bpx
pgbench -r -j100 -c200  -T1000 bpx1

查看连接数

select datname,state,count(*) from pg_stat_activity group by 1,2;
pgbench --help 
pgbench is a benchmarking tool for Vastbase.

Usage:
  pgbench [OPTION]... [DBNAME]

Initialization options:
  -i           invokes initialization mode
  -m           use memory tables (mot)
  -F NUM       fill factor
  -k           distribute by primary key branch id - bid
  -s NUM       scaling factor
  --index-tablespace=TABLESPACE
               create indexes in the specified tablespace
  --tablespace=TABLESPACE
               create tables in the specified tablespace
  --unlogged-tables
               create tables as unlogged tables

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
  -k           query with default key and additional key branch id (bid)
  -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"
  -O row|column|orc
               Table orientation option
  -P NUM       show thread progress report every NUM seconds
  -r           report average latency per command
  -R, --rate=NUM
               target rate in transactions per second
  -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
  -W PASSWORD    connect as specified database user through explicit password
  -V, --version  output version information, then exit
  -?, --help     show this help, then exit

pgbench 使用介绍及示例

你可能感兴趣的:(PG,数据库)