数据库基准测试4:HammerDB测试脚本运用(for Oracle)

0.前面要说的话

之前章节简单介绍了一下hammerdbcli的使用方法,但通过命令行的方式不适合大批量数据基准测试(灌了3000仓库的tpcc数据在虚拟 机上耗时超过了1天多),实际hammerdb已经内置了多种数据库类型的基准测试脚本,以下以oracle为例简单说明如何使用这些脚本。

1.基准测试脚本

HammerDB自带的DB2 TPC-C测试脚本的路径是/opt/HammerDB-5.0/scripts/tcl/oracle/tprocc,主要内容有以下,为方便修改,复制一个/tprocc目录为/tprocc_aix,方便后续修改。

[root@xxx ~]# cd /opt/HammerDB-5.0/scripts/tcl/oracle/tprocc
[root@xxx tprocc]# ll
total 28
-rw-r--r-- 1 root root  690 Jul 30 15:20 ora_tprocc_buildschema.tcl
-rw-r--r-- 1 root root  361 Jul 30 15:20 ora_tprocc_checkschema.tcl
-rw-r--r-- 1 root root  360 Jul 30 15:20 ora_tprocc_deleteschema.tcl
-rw-r--r-- 1 root root 1025 Jul 30 15:20 ora_tprocc.ps1
-rw-r--r-- 1 root root  116 Jul 30 15:20 ora_tprocc_result.tcl
-rw-r--r-- 1 root root  673 Jul 30 15:20 ora_tprocc_run.tcl
-rw-r--r-- 1 root root  965 Jul 30 15:20 ora_tprocc.sh

首先看ora_tprocc.sh,这个脚本实际是将buildschema、checkschema、run、deleteschema、result几个过程放在一起执行,对于大测试而言,此脚本最好拆成多个执行。

2.测试脚本的修改

2.1.buildschema的修改

修改ora_tprocc_buildschema.tcl.tcl

参考以下中文注释进行修改,下同

#!/bin/tclsh
# maintainer: Pooja Jain

puts "SETTING CONFIGURATION"
dbset db ora
dbset bm TPC-C

diset connection system_user hammerdb
diset connection system_password my_passwd
diset connection instance 192.168.1.62:1521/testdb


diset tpcc count_ware 3000
diset tpcc num_vu 32
diset tpcc tpcc_user hammerdb
diset tpcc tpcc_pass my_passwd
diset tpcc tpcc_def_tab users
diset tpcc tpcc_def_temp temp
diset tpcc partition true
diset tpcc hash_clusters false
diset tpcc tpcc_ol_tab users
diset tpcc rampup 2
diset tpcc duration 5

puts "SCHEMA BUILD STARTED"
buildschema
puts "SCHEMA BUILD COMPLETED"

2.2.checkschema的修改

修改ora_tprocc_checkschema.tcl

#!/bin/tclsh
# maintainer: Pooja Jain

dbset db ora
dbset bm TPC-C

puts "SETTING CONFIGURATION"
dbset db ora
dbset bm TPC-C

diset connection system_user hammerdb
diset connection system_password my_passwd
diset connection instance 192.168.1.62:1521/testdb

diset tpcc tpcc_user hammerdb
diset tpcc tpcc_pass my_passwd


puts "CHECK SCHEMA STARTED"
checkschema
puts "CHECK SCHEMA COMPLETED"

2.3.run的修改

修改ora_tprocc_run.tcl

#!/bin/tclsh
# maintainer: Pooja Jain

set tmpdir $::env(TMP)
puts "SETTING CONFIGURATION"
dbset db ora
dbset bm TPC-C

diset connection system_user hammerdb
diset connection system_password my_passwd
diset connection instance 192.168.1.62:1521/testdb

diset tpcc tpcc_user hammerdb
diset tpcc tpcc_pass my_passwd

diset tpcc ora_driver timed
diset tpcc total_iterations 10000000
diset tpcc rampup 2
diset tpcc duration 5
diset tpcc ora_timeprofile true
diset tpcc allwarehouse true
diset tpcc checkpoint false

loadscript
puts "TEST STARTED"
vuset vu 32
vucreate
tcstart
tcstatus
set jobid [ vurun ]
vudestroy
tcstop
puts "TEST COMPLETE"
set of [ open $tmpdir/ora_tprocc w ]
puts $of $jobid
close $of

2.4.delete及result的修改

  • ora_tprocc_deleteschema.tcl脚本不建议执行,因为有多次执行的需要;
  • ora_tprocc_result.tcl脚本不需要修改
  • ora_tprocc.sh也不建议执行,手工单步执行更好一点

2.5.拆分执行脚本的修改

事实最好将ora_tprocc.sh脚本折成三个,独立进行:

  • 01.build.sh
export TMP=`pwd`/TMP
mkdir -p $TMP

home_dir=/opt/HammerDB-5.0    # 增加home_dir参数,方便在'tprocc_1'当前目录下执行脚本
cur_dir=tprocc_aix            # 将默认的'tprocc'目录修改为'tprocc_1'目录,以下对应做修改

echo "BUILD HAMMERDB SCHEMA"
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"
${home_dir}/hammerdbcli auto ./scripts/tcl/oracle/${cur_dir}/ora_tprocc_buildschema.tcl
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"
echo "CHECK HAMMERDB SCHEMA"
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"
${home_dir}/hammerdbcli auto ./scripts/tcl/oracle/${cur_dir}/ora_tprocc_checkschema.tcl
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"
  • 02.check.sh
export TMP=`pwd`/TMP
mkdir -p $TMP

home_dir=/opt/HammerDB-5.0    # 增加home_dir参数,方便在'tprocc_1'当前目录下执行脚本
cur_dir=tprocc_aix              # 将默认的'tprocc'目录修改为'tprocc_1'目录,以下对应做修改

echo "CHECK HAMMERDB SCHEMA"
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"
${home_dir}/hammerdbcli auto ./scripts/tcl/oracle/${cur_dir}/ora_tprocc_checkschema.tcl
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"

  • 03.run.sh
export TMP=`pwd`/TMP
mkdir -p $TMP

home_dir=/opt/HammerDB-5.0    # 增加home_dir参数,方便在'tprocc_1'当前目录下执行脚本
cur_dir=tprocc_aix              # 将默认的'tprocc'目录修改为'tprocc_1'目录,以下对应做修改

echo "RUN HAMMERDB TEST"
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"
${home_dir}/hammerdbcli auto ./scripts/tcl/oracle/${cur_dir}/ora_tprocc_run.tcl
echo "+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-"
echo "HAMMERDB RESULT"
${home_dir}/hammerdbcli auto ./scripts/tcl/oracle/${cur_dir}/ora_tprocc_result.tcl

3.执行基准测试

对HammerDB的脚本处理完成之后,按以下步骤执行基准测试:

  • 执行01.build.sh,加载测试数据,这个过程十分漫长,建议使用nohup后台执行;
  • 执行02.check.sh,检查数据是否有问题,有概率在上一步骤加载测试数据量不足,导致check失败;
  • 执行03.rub.sh,按print dict中tpc-c的基准测试,会启动虚拟用户执行共1000万个事务操作,在操作完成输出以下测试结果:
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
HAMMERDB RESULT
HammerDB CLI v5.0
Copyright © HammerDB Ltd hosted by tpc.org 2019-2025
Type "help" for a list of commands
Usage: hammerdbcli [ tcl|python [ auto [ script_to_autoload.[ tcl|py ] ] ] ]
Initialized Jobs on-disk database /opt/HammerDB-5.0/scripts/tcl/oracle/tprocc_aix/TMP/hammer.DB using existing tables (13,287,424 bytes)
TRANSACTION RESPONSE TIMES
{
  "NEWORD": {
    "elapsed_ms": "421900.5",
    "calls": "259294",
    "min_ms": "3.573",
    "avg_ms": "33.823",
    "max_ms": "3022.898",
    "total_ms": "8770332.075",
    "p99_ms": "373.239",
    "p95_ms": "117.07",
    "p50_ms": "14.628",
    "sd": "108677.826",
    "ratio_pct": "64.962"
  },
  "PAYMENT": {
    "elapsed_ms": "421900.5",
    "calls": "259706",
    "min_ms": "1.421",
    "avg_ms": "11.035",
    "max_ms": "2981.316",
    "total_ms": "2865928.233",
    "p99_ms": "153.627",
    "p95_ms": "16.947",
    "p50_ms": "4.347",
    "sd": "62516.826",
    "ratio_pct": "21.228"
  },
  "DELIVERY": {
    "elapsed_ms": "421900.5",
    "calls": "25778",
    "min_ms": "7.055",
    "avg_ms": "38.295",
    "max_ms": "3041.013",
    "total_ms": "987188.343",
    "p99_ms": "376.191",
    "p95_ms": "131.793",
    "p50_ms": "17.336",
    "sd": "122269.254",
    "ratio_pct": "7.312"
  },
  "SLEV": {
    "elapsed_ms": "421900.5",
    "calls": "26132",
    "min_ms": "2.391",
    "avg_ms": "24.579",
    "max_ms": "2950.456",
    "total_ms": "642316.905",
    "p99_ms": "268.744",
    "p95_ms": "69.19",
    "p50_ms": "8.601",
    "sd": "60001.272",
    "ratio_pct": "4.758"
  },
  "OSTAT": {
    "elapsed_ms": "421900.5",
    "calls": "25842",
    "min_ms": "1.183",
    "avg_ms": "8.329",
    "max_ms": "508.925",
    "total_ms": "215238.474",
    "p99_ms": "113.531",
    "p95_ms": "23.129",
    "p50_ms": "3.876",
    "sd": "21466.349",
    "ratio_pct": "1.594"
  }
}

TRANSACTION COUNT
{"Oracle tpm": {
    "2025-11-04 11:39:53": "0",
    "2025-11-04 11:40:03": "27468",
    "2025-11-04 11:40:13": "23274",
    "2025-11-04 11:40:23": "20046",
    "2025-11-04 11:40:33": "18816",
    "2025-11-04 11:40:43": "20790",
    "2025-11-04 11:40:53": "25176",
    "2025-11-04 11:41:03": "29466",
    "2025-11-04 11:41:13": "33660",
    "2025-11-04 11:41:23": "32826",
    "2025-11-04 11:41:33": "38628",
    "2025-11-04 11:41:43": "38796",
    "2025-11-04 11:41:53": "39192",
    "2025-11-04 11:42:03": "40164",
    "2025-11-04 11:42:13": "46362",
    "2025-11-04 11:42:23": "34242",
    "2025-11-04 11:42:33": "39486",
    "2025-11-04 11:42:43": "47214",
    "2025-11-04 11:42:53": "40920",
    "2025-11-04 11:43:03": "32532",
    "2025-11-04 11:43:14": "43950",
    "2025-11-04 11:43:24": "43980",
    "2025-11-04 11:43:34": "37062",
    "2025-11-04 11:43:44": "44136",
    "2025-11-04 11:43:54": "46986",
    "2025-11-04 11:44:04": "48348",
    "2025-11-04 11:44:14": "42900",
    "2025-11-04 11:44:24": "36558",
    "2025-11-04 11:44:34": "34560",
    "2025-11-04 11:44:44": "36732",
    "2025-11-04 11:44:54": "41094",
    "2025-11-04 11:45:04": "30978",
    "2025-11-04 11:45:14": "39696",
    "2025-11-04 11:45:24": "36684",
    "2025-11-04 11:45:34": "43596",
    "2025-11-04 11:45:44": "37032",
    "2025-11-04 11:45:54": "47124",
    "2025-11-04 11:46:04": "39810",
    "2025-11-04 11:46:14": "40494",
    "2025-11-04 11:46:24": "43566",
    "2025-11-04 11:46:34": "51930",
    "2025-11-04 11:46:44": "53448",
    "2025-11-04 11:46:54": "60054"
  }}

HAMMERDB RESULT
[
  "6909758995B703E273837333",
  "2025-11-04 11:39:53",
  "16 Active Virtual Users configured",
  "TEST RESULT : System achieved 20006 NOPM from 41926 Oracle TPM"
]

4.一些问题

  • oracle归档日志满

当压入3000个仓库的数据时,总的数据量约200GB,在buildschema时,如果开启了归档日志,需要确认归档日志磁盘的空间可用,因为在build的过程即使日志满并不会报错(输出的日志一直卡住不动),事后要杀掉HammerDB产生的session也很麻烦。

  • 创建索引及存储过程失败

在build阶段的最后,会创建对应的索引及存储过程,但有概率失败,这是可以手动执行相关的创建作业,如以下:

-- 逐个执行索引创建语句(按顺序执行,确保无报错)
CREATE UNIQUE INDEX CUSTOMER_I1 ON CUSTOMER ( C_W_ID, C_D_ID, C_ID) INITRANS 4 PCTFREE 10;
CREATE UNIQUE INDEX CUSTOMER_I2 ON CUSTOMER ( C_LAST, C_W_ID, C_D_ID, C_FIRST, C_ID) INITRANS 4 PCTFREE 10;
CREATE UNIQUE INDEX DISTRICT_I1 ON DISTRICT ( D_W_ID, D_ID) INITRANS 4 PCTFREE 10;
CREATE UNIQUE INDEX ITEM_I1 ON ITEM (I_ID) INITRANS 4 PCTFREE 10;
CREATE UNIQUE INDEX ORDERS_I1 ON ORDERS (O_W_ID, O_D_ID, O_ID) INITRANS 4 PCTFREE 10 LOCAL;
CREATE UNIQUE INDEX ORDERS_I2 ON ORDERS (O_W_ID, O_D_ID, O_C_ID, O_ID) INITRANS 4 PCTFREE 10 LOCAL;
CREATE UNIQUE INDEX STOCK_I1 ON STOCK (S_I_ID, S_W_ID) INITRANS 4 PCTFREE 10;
CREATE UNIQUE INDEX WAREHOUSE_I1 ON WAREHOUSE (W_ID) INITRANS 4 PCTFREE 10;
-- 直接执行存储过程创建语句(复制报错中的完整代码)
CREATE OR REPLACE PROCEDURE DMPMON.NEWORD ( 
    no_w_id BINARY_INTEGER, 
    no_max_w_id BINARY_INTEGER, 
    no_d_id BINARY_INTEGER, 
    no_c_id BINARY_INTEGER, 
    no_o_ol_cnt BINARY_INTEGER, 
    no_c_discount OUT NUMBER, 
    no_c_last OUT VARCHAR2, 
    no_c_credit OUT VARCHAR2, 
    no_d_tax OUT NUMBER, 
    no_w_tax OUT NUMBER, 
    no_d_next_o_id OUT BINARY_INTEGER, 
    timestamp IN DATE 
) IS 
    order_amount NUMBER; 
    no_o_all_local BINARY_INTEGER; 
    loop_counter BINARY_INTEGER; 
    not_serializable EXCEPTION; 
    PRAGMA EXCEPTION_INIT(not_serializable,-8177); 
    deadlock EXCEPTION; 
    PRAGMA EXCEPTION_INIT(deadlock,-60); 
    snapshot_too_old EXCEPTION; 
    PRAGMA EXCEPTION_INIT(snapshot_too_old,-1555); 
    integrity_viol EXCEPTION; 
    PRAGMA EXCEPTION_INIT(integrity_viol,-1); 
    TYPE intarray IS TABLE OF INTEGER index by binary_integer; 
    TYPE numarray IS TABLE OF NUMBER index by binary_integer; 
    TYPE distarray IS TABLE OF VARCHAR(24) index by binary_integer; 
    o_id_array intarray; 
    w_id_array intarray; 
    o_quantity_array intarray; 
    s_quantity_array intarray; 
    ol_line_number_array intarray; 
    amount_array numarray; 
    district_info distarray; 
BEGIN 
    SELECT c_discount, c_last, c_credit, w_tax 
    INTO no_c_discount, no_c_last, no_c_credit, no_w_tax 
    FROM customer, warehouse 
    WHERE warehouse.w_id = no_w_id 
      AND customer.c_w_id = no_w_id 
      AND customer.c_d_id = no_d_id 
      AND customer.c_id = no_c_id; 

    no_o_all_local := 1; 
    FOR loop_counter IN 1 .. no_o_ol_cnt LOOP 
        o_id_array(loop_counter) := round(DBMS_RANDOM.value(low => 1, high => 100000)); 
        IF ( DBMS_RANDOM.value >= 0.01 ) THEN 
            w_id_array(loop_counter) := no_w_id; 
        ELSE 
            no_o_all_local := 0; 
            w_id_array(loop_counter) := 1 + mod(no_w_id + round(DBMS_RANDOM.value(low => 0, high => no_max_w_id-1)),no_max_w_id); 
        END IF; 
        o_quantity_array(loop_counter) := round(DBMS_RANDOM.value(low => 1, high => 10)); 
        ol_line_number_array(loop_counter) := loop_counter; 
    END LOOP; 

    UPDATE district 
    SET d_next_o_id = d_next_o_id + 1 
    WHERE d_id = no_d_id AND d_w_id = no_w_id 
    RETURNING d_next_o_id - 1, d_tax INTO no_d_next_o_id, no_d_tax; 

    INSERT INTO ORDERS (o_id, o_d_id, o_w_id, o_c_id, o_entry_d, o_ol_cnt, o_all_local) 
    VALUES (no_d_next_o_id, no_d_id, no_w_id, no_c_id, timestamp, no_o_ol_cnt, no_o_all_local); 

    INSERT INTO NEW_ORDER (no_o_id, no_d_id, no_w_id) 
    VALUES (no_d_next_o_id, no_d_id, no_w_id); 

    IF no_d_id = 1 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_01, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array, amount_array; 
    ELSIF no_d_id = 2 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_02, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array,amount_array; 
    ELSIF no_d_id = 3 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_03, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array,amount_array; 
    ELSIF no_d_id = 4 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_04, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array,amount_array; 
    ELSIF no_d_id = 5 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_05, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array,amount_array; 
    ELSIF no_d_id = 6 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_06, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array,amount_array; 
    ELSIF no_d_id = 7 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_07, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array,amount_array; 
    ELSIF no_d_id = 8 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_08, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array,amount_array; 
    ELSIF no_d_id = 9 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_09, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array,amount_array; 
    ELSIF no_d_id = 10 THEN 
        FORALL i IN 1 .. no_o_ol_cnt 
        UPDATE stock_item 
        SET s_quantity = (CASE WHEN s_quantity < ( o_quantity_array(i) + 10 ) THEN s_quantity + 91 ELSE s_quantity END) - o_quantity_array(i) 
        WHERE i_id = o_id_array(i) AND s_w_id = w_id_array(i) 
        RETURNING s_dist_10, s_quantity, i_price * o_quantity_array(i) 
        BULK COLLECT INTO district_info, s_quantity_array,amount_array; 
    END IF; 

    order_amount := 0; 
    FOR loop_counter IN 1 .. no_o_ol_cnt LOOP 
        order_amount := order_amount + ( amount_array(loop_counter) ); 
    END LOOP; 
    order_amount := order_amount * ( 1 + no_w_tax + no_d_tax ) * ( 1 - no_c_discount ); 

    FORALL i IN 1 .. no_o_ol_cnt 
    INSERT INTO order_line (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_dist_info) 
    VALUES (no_d_next_o_id, no_d_id, no_w_id, ol_line_number_array(i), o_id_array(i), w_id_array(i), o_quantity_array(i), amount_array(i), district_info(i)); 

    IF DBMS_RANDOM.value < 0.01 THEN 
        dbms_output.put_line('Rolling back'); 
        ROLLBACK; 
    ELSE 
        COMMIT; 
    END IF; 

EXCEPTION 
    WHEN not_serializable OR deadlock OR snapshot_too_old OR integrity_viol THEN 
        ROLLBACK; 
END;
  • 表空间的问题

有一个很奇怪的问题,即使用设置了新的表空间diset tpcc tpcc_def_tab tpcc,但HammerDB并不认这个设定,始终将数据灌到USERS表空间下,所以要注意对此表空间的datafile的容量做好提前确认工作。

  • NOPM值缺失

如果执行压测时,发现只有tpm的值但没有NOPM的值,此时则需要检查所建的存储过程是否有缺失或无效。

5.总结

通过修改HammerDB自带的脚本还是很方便进行基准测试的,修改参数也很方便,至于基准测试结果的解读,放到下次说明。

posted @ 2025-11-04 11:50  潇雨锁清秋  阅读(5)  评论(0)    收藏  举报