一、简介 An easy to use JDBC benchmark that closely resembles the TPC-C standard for OLTP. RDBMS's presently supported include Postgre
sql,EnterpriseDB and Oracle. 二、安装配置 下载地址:http://sourceforge.net/projects/benchmark
sql/?source=navbar
required:JDK7 Postgre
sql Version:9.3.4 解压: [postgres@localhost ~]$ unzip benchmark
sql-4.1.0.zip 保留配置备份: [postgres@localhost ~]$ cd benchmark
sql-4.1.0/run/ [postgres@localhost run]$ cp props.pg props.pg.bak
修改数据库连接配置: [postgres@localhost run]$ vi props.pg driver=org.postgre
sql.Driver conn=jdbc:postgre
sql://localhost:5432/benchmark
sql user=benchmark
sql password=password warehouses=1 terminals=1 //To run specified transactions per terminal- runMins must equal zero runTxnsPerTerminal=10 //To run for specified minutes- runTxnsPerTerminal must equal zero runMins=0 //Number of total transactions per minute limitTxnsPerMin=300 //The following five values must add up to 100 //The default percentages of 45,43,4,4 & 4 match the TPC-C spec newOrderWeight=45 paymentWeight=43 orderStatusWeight=4 deliveryWeight=4 stockLevelWeight=4 创建测试库: postgres=# create user benchmark
sql with superuser password 'password'; CREATE ROLE postgres=# create database benchmark
sql owner benchmark
sql; CREATE DATABASE 创建测试表结构: [postgres@localhost run]$ ./run
sql.sh props.pg
sqlTableCreates 查看测试表: [postgres@localhost run]$ p
sql benchmark
sql benchmark
sql p
sql (9.3.4) Type "help" for help. benchmark
sql=# \d List of relations Schema | Name | Type | Owner --------------+-------------+----------+-------------- benchmark
sql | customer | table | benchmark
sql benchmark
sql | district | table | benchmark
sql benchmark
sql | hist_id_seq | sequence | benchmark
sql benchmark
sql | history | table | benchmark
sql benchmark
sql | item | table | benchmark
sql benchmark
sql | new_order | table | benchmark
sql benchmark
sql | oorder | table | benchmark
sql benchmark
sql | order_line | table | benchmark
sql benchmark
sql | stock | table | benchmark
sql benchmark
sql | warehouse | table | benchmark
sql (10 rows) 导入测试数据: [postgres@localhost run]$ ./runLoader.sh props.pg numWarehouses 1 查看表: benchmark
sql=# \d+ List of relations Schema | Name | Type | Owner | Size | Description --------------+-------------+----------+--------------+------------+------------- benchmark
sql | customer | table | benchmark
sql | 18 MB | benchmark
sql | district | table | benchmark
sql | 8192 bytes | benchmark
sql | hist_id_seq | sequence | benchmark
sql | 8192 bytes | benchmark
sql | history | table | benchmark
sql | 2552 kB | benchmark
sql | item | table | benchmark
sql | 10192 kB | benchmark
sql | new_order | table | benchmark
sql | 416 kB | benchmark
sql | oorder | table | benchmark
sql | 2024 kB | benchmark
sql | order_line | table | benchmark
sql | 30 MB | benchmark
sql | stock | table | benchmark
sql | 34 MB | benchmark
sql | warehouse | table | benchmark
sql | 8192 bytes | (10 rows) benchmark
sql=# select count(*) from customer ; count ------- 30000 (1 row) benchmark
sql=# select * from warehouse; w_id | w_ytd | w_tax | w_name | w_street_1 | w_street_2 | w_city | w_state | w_zip ------+-----------+--------+--------+---------------------+--------------+--------------+---------+----------- 1 | 300000.00 | 0.0445 | RfHUW | HldcTUzsMXqRYwvseXe | TgpQzWZsRMCc | WgCgqczSIpzF | DT | 123456789 (1 row) 为测试表创建索引: [postgres@localhost run]$ ./run
sql.sh props.pg
sqlIndexCreates 查看索引: benchmark
sql=# \di List of relations Schema | Name | Type | Owner | Table --------------+--------------------+-------+--------------+------------ benchmark
sql | history_pkey | index | benchmark
sql | history benchmark
sql | ndx_customer_name | index | benchmark
sql | customer benchmark
sql | ndx_oorder_carrier | index | benchmark
sql | oorder benchmark
sql | pk_customer | index | benchmark
sql | customer benchmark
sql | pk_district | index | benchmark
sql | district benchmark
sql | pk_item | index | benchmark
sql | item benchmark
sql | pk_new_order | index | benchmark
sql | new_order benchmark
sql | pk_oorder | index | benchmark
sql | oorder benchmark
sql | pk_order_line | index | benchmark
sql | order_line benchmark
sql | pk_stock | index | benchmark
sql | stock benchmark
sql | pk_warehouse | index | benchmark
sql | warehouse (11 rows) 至此配置完成。 若需要重新导入数据,则无需
删除表结构,只需在导入前执行: ./run
sql.sh props.pg
sqlTableTruncates 三、测试 [postgres@localhost run]$ ./runBenchmark.sh props.pg 2014-05-13 06:58:56,125 INFO - Term-00,2014-05-13 06:58:56,129 INFO - Term-00,+-------------------------------------------------------------+ 2014-05-13 06:58:56,Benchmark
sql v4.1 2014-05-13 06:58:56,(c) 2003,Raul Barbosa 2014-05-13 06:58:56,130 INFO - Term-00,(c) 2004-2014,Denis Lussier 2014-05-13 06:58:56,132 INFO - Term-00,133 INFO - Term-00,134 INFO - Term-00,driver=org.postgre
sql.Driver 2014-05-13 06:58:56,135 INFO - Term-00,conn=jdbc:postgre
sql://localhost:5432/benchmark
sql 2014-05-13 06:58:56,136 INFO - Term-00,user=benchmark
sql 2014-05-13 06:58:56,137 INFO - Term-00,138 INFO - Term-00,warehouses=1 2014-05-13 06:58:56,terminals=1 2014-05-13 06:58:56,140 INFO - Term-00,runTxnsPerTerminal=10 2014-05-13 06:58:56,141 INFO - Term-00,limitTxnsPerMin=300 2014-05-13 06:58:56,142 INFO - Term-00,newOrderWeight=45 2014-05-13 06:58:56,143 INFO - Term-00,paymentWeight=43 2014-05-13 06:58:56,144 INFO - Term-00,orderStatusWeight=4 2014-05-13 06:58:56,145 INFO - Term-00,deliveryWeight=4 2014-05-13 06:58:56,146 INFO - Term-00,stockLevelWeight=4 2014-05-13 06:58:56,2014-05-13 06:58:58,480 INFO - Term-00,Current tpmTOTAL: 12 Memory Usage: 6MB / 15MB 2014-05-13 06:58:58,481 INFO - Term-00,Measured tpmC (NewOrders) = 86.16 2014-05-13 06:58:58,482 INFO - Term-00,Measured tpmTOTAL = 315.94 2014-05-13 06:58:58,485 INFO - Term-00,Session Start = 2014-05-13 06:58:56 2014-05-13 06:58:58,Session End = 2014-05-13 06:58:58 2014-05-13 06:58:58,487 INFO - Term-00,Transaction Count = 10 改变测试方案只需在执行测试前
修改props.pg即可。
原文链接:https://www.f2er.com/postgresql/195667.html