Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
e64ccfd2
提交
e64ccfd2
authored
8月 04, 2009
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Delete old databases before testing; small formatting changes; use standard statements.
上级
5dbcd675
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
175 行增加
和
96 行删除
+175
-96
BenchC.java
h2/src/test/org/h2/test/bench/BenchC.java
+161
-68
BenchCThread.java
h2/src/test/org/h2/test/bench/BenchCThread.java
+10
-21
TestPerformance.java
h2/src/test/org/h2/test/bench/TestPerformance.java
+4
-7
没有找到文件。
h2/src/test/org/h2/test/bench/BenchC.java
浏览文件 @
e64ccfd2
...
@@ -24,69 +24,145 @@ public class BenchC implements Bench {
...
@@ -24,69 +24,145 @@ public class BenchC implements Bench {
private
static
final
String
[]
TABLES
=
new
String
[]
{
"WAREHOUSE"
,
"DISTRICT"
,
"CUSTOMER"
,
"HISTORY"
,
"ORDERS"
,
private
static
final
String
[]
TABLES
=
new
String
[]
{
"WAREHOUSE"
,
"DISTRICT"
,
"CUSTOMER"
,
"HISTORY"
,
"ORDERS"
,
"NEW_ORDER"
,
"ITEM"
,
"STOCK"
,
"ORDER_LINE"
,
"RESULTS"
};
"NEW_ORDER"
,
"ITEM"
,
"STOCK"
,
"ORDER_LINE"
,
"RESULTS"
};
private
static
final
String
[]
CREATE_SQL
=
new
String
[]
{
private
static
final
String
[]
CREATE_SQL
=
new
String
[]
{
"CREATE TABLE WAREHOUSE(\n"
+
" W_ID INT NOT NULL PRIMARY KEY,\n"
+
" W_NAME VARCHAR(10),\n"
"CREATE TABLE WAREHOUSE(\n"
+
+
" W_STREET_1 VARCHAR(20),\n"
+
" W_STREET_2 VARCHAR(20),\n"
+
" W_CITY VARCHAR(20),\n"
" W_ID INT NOT NULL PRIMARY KEY,\n"
+
+
" W_STATE CHAR(2),\n"
+
" W_ZIP CHAR(9),\n"
+
" W_TAX DECIMAL(4, 4),\n"
" W_NAME VARCHAR(10),\n"
+
+
" W_YTD DECIMAL(12, 2))"
,
" W_STREET_1 VARCHAR(20),\n"
+
"CREATE TABLE DISTRICT(\n"
+
" D_ID INT NOT NULL,\n"
+
" D_W_ID INT NOT NULL,\n"
" W_STREET_2 VARCHAR(20),\n"
+
+
" D_NAME VARCHAR(10),\n"
+
" D_STREET_1 VARCHAR(20),\n"
+
" D_STREET_2 VARCHAR(20),\n"
" W_CITY VARCHAR(20),\n"
+
+
" D_CITY VARCHAR(20),\n"
+
" D_STATE CHAR(2),\n"
+
" D_ZIP CHAR(9),\n"
" W_STATE CHAR(2),\n"
+
+
" D_TAX DECIMAL(4, 4),\n"
+
" D_YTD DECIMAL(12, 2),\n"
+
" D_NEXT_O_ID INT,\n"
" W_ZIP CHAR(9),\n"
+
+
" PRIMARY KEY (D_ID, D_W_ID))"
,
" W_TAX DECIMAL(4, 4),\n"
+
" W_YTD DECIMAL(12, 2))"
,
"CREATE TABLE DISTRICT(\n"
+
" D_ID INT NOT NULL,\n"
+
" D_W_ID INT NOT NULL,\n"
+
" D_NAME VARCHAR(10),\n"
+
" D_STREET_1 VARCHAR(20),\n"
+
" D_STREET_2 VARCHAR(20),\n"
+
" D_CITY VARCHAR(20),\n"
+
" D_STATE CHAR(2),\n"
+
" D_ZIP CHAR(9),\n"
+
" D_TAX DECIMAL(4, 4),\n"
+
" D_YTD DECIMAL(12, 2),\n"
+
" D_NEXT_O_ID INT,\n"
+
" PRIMARY KEY (D_ID, D_W_ID))"
,
// + " FOREIGN KEY (D_W_ID)\n"
// + " FOREIGN KEY (D_W_ID)\n"
// + " REFERENCES WAREHOUSE(W_ID))",
// + " REFERENCES WAREHOUSE(W_ID))",
"CREATE TABLE CUSTOMER(\n"
+
" C_ID INT NOT NULL,\n"
+
" C_D_ID INT NOT NULL,\n"
"CREATE TABLE CUSTOMER(\n"
+
+
" C_W_ID INT NOT NULL,\n"
+
" C_FIRST VARCHAR(16),\n"
+
" C_MIDDLE CHAR(2),\n"
" C_ID INT NOT NULL,\n"
+
+
" C_LAST VARCHAR(16),\n"
+
" C_STREET_1 VARCHAR(20),\n"
+
" C_STREET_2 VARCHAR(20),\n"
" C_D_ID INT NOT NULL,\n"
+
+
" C_CITY VARCHAR(20),\n"
+
" C_STATE CHAR(2),\n"
+
" C_ZIP CHAR(9),\n"
+
" C_PHONE CHAR(16),\n"
" C_W_ID INT NOT NULL,\n"
+
+
" C_SINCE TIMESTAMP,\n"
+
" C_CREDIT CHAR(2),\n"
+
" C_CREDIT_LIM DECIMAL(12, 2),\n"
" C_FIRST VARCHAR(16),\n"
+
+
" C_DISCOUNT DECIMAL(4, 4),\n"
+
" C_BALANCE DECIMAL(12, 2),\n"
" C_MIDDLE CHAR(2),\n"
+
+
" C_YTD_PAYMENT DECIMAL(12, 2),\n"
+
" C_PAYMENT_CNT DECIMAL(4),\n"
" C_LAST VARCHAR(16),\n"
+
+
" C_DELIVERY_CNT DECIMAL(4),\n"
+
" C_DATA VARCHAR(500),\n"
" C_STREET_1 VARCHAR(20),\n"
+
+
" PRIMARY KEY (C_W_ID, C_D_ID, C_ID))"
,
" C_STREET_2 VARCHAR(20),\n"
+
" C_CITY VARCHAR(20),\n"
+
" C_STATE CHAR(2),\n"
+
" C_ZIP CHAR(9),\n"
+
" C_PHONE CHAR(16),\n"
+
" C_SINCE TIMESTAMP,\n"
+
" C_CREDIT CHAR(2),\n"
+
" C_CREDIT_LIM DECIMAL(12, 2),\n"
+
" C_DISCOUNT DECIMAL(4, 4),\n"
+
" C_BALANCE DECIMAL(12, 2),\n"
+
" C_YTD_PAYMENT DECIMAL(12, 2),\n"
+
" C_PAYMENT_CNT DECIMAL(4),\n"
+
" C_DELIVERY_CNT DECIMAL(4),\n"
+
" C_DATA VARCHAR(500),\n"
+
" PRIMARY KEY (C_W_ID, C_D_ID, C_ID))"
,
// + " FOREIGN KEY (C_W_ID, C_D_ID)\n"
// + " FOREIGN KEY (C_W_ID, C_D_ID)\n"
// + " REFERENCES DISTRICT(D_W_ID, D_ID))",
// + " REFERENCES DISTRICT(D_W_ID, D_ID))",
"CREATE INDEX CUSTOMER_NAME ON CUSTOMER(C_LAST, C_D_ID, C_W_ID)"
,
"CREATE INDEX CUSTOMER_NAME ON CUSTOMER(C_LAST, C_D_ID, C_W_ID)"
,
"CREATE TABLE HISTORY(\n"
+
" H_C_ID INT,\n"
+
" H_C_D_ID INT,\n"
+
" H_C_W_ID INT,\n"
+
" H_D_ID INT,\n"
"CREATE TABLE HISTORY(\n"
+
+
" H_W_ID INT,\n"
+
" H_DATE TIMESTAMP,\n"
+
" H_AMOUNT DECIMAL(6, 2),\n"
+
" H_DATA VARCHAR(24))"
,
" H_C_ID INT,\n"
+
" H_C_D_ID INT,\n"
+
" H_C_W_ID INT,\n"
+
" H_D_ID INT,\n"
+
" H_W_ID INT,\n"
+
" H_DATE TIMESTAMP,\n"
+
" H_AMOUNT DECIMAL(6, 2),\n"
+
" H_DATA VARCHAR(24))"
,
// + " FOREIGN KEY(H_C_W_ID, H_C_D_ID, H_C_ID)\n"
// + " FOREIGN KEY(H_C_W_ID, H_C_D_ID, H_C_ID)\n"
// + " REFERENCES CUSTOMER(C_W_ID, C_D_ID, C_ID),\n"
// + " REFERENCES CUSTOMER(C_W_ID, C_D_ID, C_ID),\n"
// + " FOREIGN KEY(H_W_ID, H_D_ID)\n"
// + " FOREIGN KEY(H_W_ID, H_D_ID)\n"
// + " REFERENCES DISTRICT(D_W_ID, D_ID))",
// + " REFERENCES DISTRICT(D_W_ID, D_ID))",
"CREATE TABLE ORDERS(\n"
+
" O_ID INT NOT NULL,\n"
+
" O_D_ID INT NOT NULL,\n"
+
" O_W_ID INT NOT NULL,\n"
"CREATE TABLE ORDERS(\n"
+
+
" O_C_ID INT,\n"
+
" O_ENTRY_D TIMESTAMP,\n"
+
" O_CARRIER_ID INT,\n"
+
" O_OL_CNT INT,\n"
" O_ID INT NOT NULL,\n"
+
+
" O_ALL_LOCAL DECIMAL(1),\n"
+
" PRIMARY KEY(O_W_ID, O_D_ID, O_ID))"
,
" O_D_ID INT NOT NULL,\n"
+
" O_W_ID INT NOT NULL,\n"
+
" O_C_ID INT,\n"
+
" O_ENTRY_D TIMESTAMP,\n"
+
" O_CARRIER_ID INT,\n"
+
" O_OL_CNT INT,\n"
+
" O_ALL_LOCAL DECIMAL(1),\n"
+
" PRIMARY KEY(O_W_ID, O_D_ID, O_ID))"
,
// + " FOREIGN KEY(O_W_ID, O_D_ID, O_C_ID)\n"
// + " FOREIGN KEY(O_W_ID, O_D_ID, O_C_ID)\n"
// + " REFERENCES CUSTOMER(C_W_ID, C_D_ID, C_ID))",
// + " REFERENCES CUSTOMER(C_W_ID, C_D_ID, C_ID))",
"CREATE INDEX ORDERS_OID ON ORDERS(O_ID)"
,
"CREATE INDEX ORDERS_OID ON ORDERS(O_ID)"
,
"CREATE TABLE NEW_ORDER(\n"
+
" NO_O_ID INT NOT NULL,\n"
+
" NO_D_ID INT NOT NULL,\n"
"CREATE TABLE NEW_ORDER(\n"
+
+
" NO_W_ID INT NOT NULL,\n"
+
" PRIMARY KEY(NO_W_ID, NO_D_ID, NO_O_ID))"
,
" NO_O_ID INT NOT NULL,\n"
+
" NO_D_ID INT NOT NULL,\n"
+
" NO_W_ID INT NOT NULL,\n"
+
" PRIMARY KEY(NO_W_ID, NO_D_ID, NO_O_ID))"
,
// + " FOREIGN KEY(NO_W_ID, NO_D_ID, NO_O_ID)\n"
// + " FOREIGN KEY(NO_W_ID, NO_D_ID, NO_O_ID)\n"
// + " REFERENCES ORDER(O_W_ID, O_D_ID, O_ID))",
// + " REFERENCES ORDER(O_W_ID, O_D_ID, O_ID))",
"CREATE TABLE ITEM(\n"
+
" I_ID INT NOT NULL,\n"
+
" I_IM_ID INT,\n"
+
" I_NAME VARCHAR(24),\n"
"CREATE TABLE ITEM(\n"
+
+
" I_PRICE DECIMAL(5, 2),\n"
+
" I_DATA VARCHAR(50),\n"
+
" PRIMARY KEY(I_ID))"
,
" I_ID INT NOT NULL,\n"
+
"CREATE TABLE STOCK(\n"
+
" S_I_ID INT NOT NULL,\n"
+
" S_W_ID INT NOT NULL,\n"
" I_IM_ID INT,\n"
+
+
" S_QUANTITY DECIMAL(4),\n"
+
" S_DIST_01 CHAR(24),\n"
+
" S_DIST_02 CHAR(24),\n"
" I_NAME VARCHAR(24),\n"
+
+
" S_DIST_03 CHAR(24),\n"
+
" S_DIST_04 CHAR(24),\n"
+
" S_DIST_05 CHAR(24),\n"
" I_PRICE DECIMAL(5, 2),\n"
+
+
" S_DIST_06 CHAR(24),\n"
+
" S_DIST_07 CHAR(24),\n"
+
" S_DIST_08 CHAR(24),\n"
" I_DATA VARCHAR(50),\n"
+
+
" S_DIST_09 CHAR(24),\n"
+
" S_DIST_10 CHAR(24),\n"
+
" S_YTD DECIMAL(8),\n"
" PRIMARY KEY(I_ID))"
,
+
" S_ORDER_CNT DECIMAL(4),\n"
+
" S_REMOTE_CNT DECIMAL(4),\n"
+
" S_DATA VARCHAR(50),\n"
"CREATE TABLE STOCK(\n"
+
+
" PRIMARY KEY(S_W_ID, S_I_ID))"
,
" S_I_ID INT NOT NULL,\n"
+
" S_W_ID INT NOT NULL,\n"
+
" S_QUANTITY DECIMAL(4),\n"
+
" S_DIST_01 CHAR(24),\n"
+
" S_DIST_02 CHAR(24),\n"
+
" S_DIST_03 CHAR(24),\n"
+
" S_DIST_04 CHAR(24),\n"
+
" S_DIST_05 CHAR(24),\n"
+
" S_DIST_06 CHAR(24),\n"
+
" S_DIST_07 CHAR(24),\n"
+
" S_DIST_08 CHAR(24),\n"
+
" S_DIST_09 CHAR(24),\n"
+
" S_DIST_10 CHAR(24),\n"
+
" S_YTD DECIMAL(8),\n"
+
" S_ORDER_CNT DECIMAL(4),\n"
+
" S_REMOTE_CNT DECIMAL(4),\n"
+
" S_DATA VARCHAR(50),\n"
+
" PRIMARY KEY(S_W_ID, S_I_ID))"
,
// + " FOREIGN KEY(S_W_ID)\n"
// + " FOREIGN KEY(S_W_ID)\n"
// + " REFERENCES WAREHOUSE(W_ID),\n"
// + " REFERENCES WAREHOUSE(W_ID),\n"
// + " FOREIGN KEY(S_I_ID)\n" + " REFERENCES ITEM(I_ID))",
// + " FOREIGN KEY(S_I_ID)\n" + " REFERENCES ITEM(I_ID))",
"CREATE TABLE ORDER_LINE(\n"
+
" OL_O_ID INT NOT NULL,\n"
+
" OL_D_ID INT NOT NULL,\n"
"CREATE TABLE ORDER_LINE(\n"
+
+
" OL_W_ID INT NOT NULL,\n"
+
" OL_NUMBER INT NOT NULL,\n"
+
" OL_I_ID INT,\n"
" OL_O_ID INT NOT NULL,\n"
+
+
" OL_SUPPLY_W_ID INT,\n"
+
" OL_DELIVERY_D TIMESTAMP,\n"
+
" OL_QUANTITY DECIMAL(2),\n"
" OL_D_ID INT NOT NULL,\n"
+
+
" OL_AMOUNT DECIMAL(6, 2),\n"
+
" OL_DIST_INFO CHAR(24),\n"
" OL_W_ID INT NOT NULL,\n"
+
+
" PRIMARY KEY (OL_W_ID, OL_D_ID, OL_O_ID, OL_NUMBER))"
,
" OL_NUMBER INT NOT NULL,\n"
+
" OL_I_ID INT,\n"
+
" OL_SUPPLY_W_ID INT,\n"
+
" OL_DELIVERY_D TIMESTAMP,\n"
+
" OL_QUANTITY DECIMAL(2),\n"
+
" OL_AMOUNT DECIMAL(6, 2),\n"
+
" OL_DIST_INFO CHAR(24),\n"
+
" PRIMARY KEY (OL_W_ID, OL_D_ID, OL_O_ID, OL_NUMBER))"
,
// + " FOREIGN KEY(OL_W_ID, OL_D_ID, OL_O_ID)\n"
// + " FOREIGN KEY(OL_W_ID, OL_D_ID, OL_O_ID)\n"
// + " REFERENCES ORDER(O_W_ID, O_D_ID, O_ID),\n"
// + " REFERENCES ORDER(O_W_ID, O_D_ID, O_ID),\n"
// + " FOREIGN KEY(OL_SUPPLY_W_ID, OL_I_ID)\n"
// + " FOREIGN KEY(OL_SUPPLY_W_ID, OL_I_ID)\n"
// + " REFERENCES STOCK(S_W_ID, S_I_ID))",
// + " REFERENCES STOCK(S_W_ID, S_I_ID))",
"CREATE TABLE RESULTS(\n"
+
" ID INT NOT NULL PRIMARY KEY,\n"
+
" TERMINAL INT,\n"
+
" OPERATION INT,\n"
"CREATE TABLE RESULTS(\n"
+
+
" RESPONSE_TIME INT,\n"
+
" PROCESSING_TIME INT,\n"
+
" KEYING_TIME INT,\n"
" ID INT NOT NULL PRIMARY KEY,\n"
+
+
" THINK_TIME INT,\n"
+
" SUCCESSFUL INT,\n"
+
" NOW TIMESTAMP)"
};
" TERMINAL INT,\n"
+
" OPERATION INT,\n"
+
" RESPONSE_TIME INT,\n"
+
" PROCESSING_TIME INT,\n"
+
" KEYING_TIME INT,\n"
+
" THINK_TIME INT,\n"
+
" SUCCESSFUL INT,\n"
+
" NOW TIMESTAMP)"
};
int
warehouses
=
1
;
int
warehouses
=
1
;
int
items
=
10000
;
int
items
=
10000
;
...
@@ -155,8 +231,9 @@ public class BenchC implements Bench {
...
@@ -155,8 +231,9 @@ public class BenchC implements Bench {
private
void
loadItem
()
throws
SQLException
{
private
void
loadItem
()
throws
SQLException
{
trace
(
"Loading item table"
);
trace
(
"Loading item table"
);
boolean
[]
original
=
random
.
getBoolean
(
items
,
items
/
10
);
boolean
[]
original
=
random
.
getBoolean
(
items
,
items
/
10
);
PreparedStatement
prep
=
db
.
prepare
(
"INSERT INTO ITEM(I_ID, I_IM_ID, I_NAME, I_PRICE, I_DATA) "
PreparedStatement
prep
=
db
.
prepare
(
+
"VALUES(?, ?, ?, ?, ?)"
);
"INSERT INTO ITEM(I_ID, I_IM_ID, I_NAME, I_PRICE, I_DATA) "
+
"VALUES(?, ?, ?, ?, ?)"
);
for
(
int
id
=
1
;
id
<=
items
;
id
++)
{
for
(
int
id
=
1
;
id
<=
items
;
id
++)
{
String
name
=
random
.
getString
(
14
,
24
);
String
name
=
random
.
getString
(
14
,
24
);
BigDecimal
price
=
random
.
getBigDecimal
(
random
.
getInt
(
100
,
10000
),
2
);
BigDecimal
price
=
random
.
getBigDecimal
(
random
.
getInt
(
100
,
10000
),
2
);
...
@@ -179,8 +256,10 @@ public class BenchC implements Bench {
...
@@ -179,8 +256,10 @@ public class BenchC implements Bench {
private
void
loadWarehouse
()
throws
SQLException
{
private
void
loadWarehouse
()
throws
SQLException
{
trace
(
"Loading warehouse table"
);
trace
(
"Loading warehouse table"
);
PreparedStatement
prep
=
db
.
prepare
(
"INSERT INTO WAREHOUSE(W_ID, W_NAME, W_STREET_1, "
PreparedStatement
prep
=
db
.
prepare
(
+
"W_STREET_2, W_CITY, W_STATE, W_ZIP, W_TAX, W_YTD) "
+
"VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
"INSERT INTO WAREHOUSE(W_ID, W_NAME, W_STREET_1, "
+
"W_STREET_2, W_CITY, W_STATE, W_ZIP, W_TAX, W_YTD) "
+
"VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
for
(
int
id
=
1
;
id
<=
warehouses
;
id
++)
{
for
(
int
id
=
1
;
id
<=
warehouses
;
id
++)
{
String
name
=
random
.
getString
(
6
,
10
);
String
name
=
random
.
getString
(
6
,
10
);
String
[]
address
=
random
.
getAddress
();
String
[]
address
=
random
.
getAddress
();
...
@@ -226,13 +305,18 @@ public class BenchC implements Bench {
...
@@ -226,13 +305,18 @@ public class BenchC implements Bench {
private
void
loadCustomerSub
(
int
dId
,
int
wId
)
throws
SQLException
{
private
void
loadCustomerSub
(
int
dId
,
int
wId
)
throws
SQLException
{
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
PreparedStatement
prepCustomer
=
db
.
prepare
(
"INSERT INTO CUSTOMER(C_ID, C_D_ID, C_W_ID, "
PreparedStatement
prepCustomer
=
db
.
prepare
(
+
"C_FIRST, C_MIDDLE, C_LAST, "
+
"C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, "
"INSERT INTO CUSTOMER(C_ID, C_D_ID, C_W_ID, "
+
+
"C_PHONE, C_SINCE, C_CREDIT, "
+
"C_CREDIT_LIM, C_DISCOUNT, C_BALANCE, C_DATA, "
"C_FIRST, C_MIDDLE, C_LAST, "
+
+
"C_YTD_PAYMENT, C_PAYMENT_CNT, C_DELIVERY_CNT) "
"C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, "
+
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
"C_PHONE, C_SINCE, C_CREDIT, "
+
PreparedStatement
prepHistory
=
db
.
prepare
(
"INSERT INTO HISTORY(H_C_ID, H_C_D_ID, H_C_W_ID, "
"C_CREDIT_LIM, C_DISCOUNT, C_BALANCE, C_DATA, "
+
+
"H_W_ID, H_D_ID, H_DATE, H_AMOUNT, H_DATA) "
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
);
"C_YTD_PAYMENT, C_PAYMENT_CNT, C_DELIVERY_CNT) "
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
PreparedStatement
prepHistory
=
db
.
prepare
(
"INSERT INTO HISTORY(H_C_ID, H_C_D_ID, H_C_W_ID, "
+
"H_W_ID, H_D_ID, H_DATE, H_AMOUNT, H_DATA) "
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?)"
);
for
(
int
cId
=
1
;
cId
<=
customersPerDistrict
;
cId
++)
{
for
(
int
cId
=
1
;
cId
<=
customersPerDistrict
;
cId
++)
{
String
first
=
random
.
getString
(
8
,
16
);
String
first
=
random
.
getString
(
8
,
16
);
String
middle
=
"OE"
;
String
middle
=
"OE"
;
...
@@ -313,13 +397,19 @@ public class BenchC implements Bench {
...
@@ -313,13 +397,19 @@ public class BenchC implements Bench {
private
void
loadOrderSub
(
int
dId
,
int
wId
)
throws
SQLException
{
private
void
loadOrderSub
(
int
dId
,
int
wId
)
throws
SQLException
{
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
Timestamp
timestamp
=
new
Timestamp
(
System
.
currentTimeMillis
());
int
[]
orderid
=
random
.
getPermutation
(
ordersPerDistrict
);
int
[]
orderid
=
random
.
getPermutation
(
ordersPerDistrict
);
PreparedStatement
prepOrder
=
db
.
prepare
(
"INSERT INTO ORDERS(O_ID, O_C_ID, O_D_ID, O_W_ID, "
PreparedStatement
prepOrder
=
db
.
prepare
(
+
"O_ENTRY_D, O_CARRIER_ID, O_OL_CNT, O_ALL_LOCAL) "
+
"VALUES(?, ?, ?, ?, ?, ?, ?, 1)"
);
"INSERT INTO ORDERS(O_ID, O_C_ID, O_D_ID, O_W_ID, "
+
PreparedStatement
prepNewOrder
=
db
.
prepare
(
"INSERT INTO NEW_ORDER (NO_O_ID, NO_D_ID, NO_W_ID) "
"O_ENTRY_D, O_CARRIER_ID, O_OL_CNT, O_ALL_LOCAL) "
+
+
"VALUES (?, ?, ?)"
);
"VALUES(?, ?, ?, ?, ?, ?, ?, 1)"
);
PreparedStatement
prepLine
=
db
.
prepare
(
"INSERT INTO ORDER_LINE("
+
"OL_O_ID, OL_D_ID, OL_W_ID, OL_NUMBER, "
PreparedStatement
prepNewOrder
=
db
.
prepare
(
+
"OL_I_ID, OL_SUPPLY_W_ID, OL_QUANTITY, OL_AMOUNT, "
+
"OL_DIST_INFO, OL_DELIVERY_D)"
"INSERT INTO NEW_ORDER (NO_O_ID, NO_D_ID, NO_W_ID) "
+
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)"
);
"VALUES (?, ?, ?)"
);
PreparedStatement
prepLine
=
db
.
prepare
(
"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, OL_DELIVERY_D)"
+
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL)"
);
for
(
int
oId
=
1
,
i
=
0
;
oId
<=
ordersPerDistrict
;
oId
++)
{
for
(
int
oId
=
1
,
i
=
0
;
oId
<=
ordersPerDistrict
;
oId
++)
{
int
cId
=
orderid
[
oId
-
1
];
int
cId
=
orderid
[
oId
-
1
];
int
carrierId
=
random
.
getInt
(
1
,
10
);
int
carrierId
=
random
.
getInt
(
1
,
10
);
...
@@ -372,11 +462,12 @@ public class BenchC implements Bench {
...
@@ -372,11 +462,12 @@ public class BenchC implements Bench {
private
void
loadStock
(
int
wId
)
throws
SQLException
{
private
void
loadStock
(
int
wId
)
throws
SQLException
{
trace
(
"Loading stock table (warehouse "
+
wId
+
")"
);
trace
(
"Loading stock table (warehouse "
+
wId
+
")"
);
boolean
[]
original
=
random
.
getBoolean
(
items
,
items
/
10
);
boolean
[]
original
=
random
.
getBoolean
(
items
,
items
/
10
);
PreparedStatement
prep
=
db
.
prepare
(
"INSERT INTO STOCK(S_I_ID, S_W_ID, S_QUANTITY, "
PreparedStatement
prep
=
db
.
prepare
(
+
"S_DIST_01, S_DIST_02, S_DIST_03, S_DIST_04, S_DIST_05, "
"INSERT INTO STOCK(S_I_ID, S_W_ID, S_QUANTITY, "
+
+
"S_DIST_06, S_DIST_07, S_DIST_08, S_DIST_09, S_DIST_10, "
"S_DIST_01, S_DIST_02, S_DIST_03, S_DIST_04, S_DIST_05, "
+
+
"S_DATA, S_YTD, S_ORDER_CNT, S_REMOTE_CNT) "
"S_DIST_06, S_DIST_07, S_DIST_08, S_DIST_09, S_DIST_10, "
+
+
"VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
"S_DATA, S_YTD, S_ORDER_CNT, S_REMOTE_CNT) "
+
"VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
for
(
int
id
=
1
;
id
<=
items
;
id
++)
{
for
(
int
id
=
1
;
id
<=
items
;
id
++)
{
int
quantity
=
random
.
getInt
(
10
,
100
);
int
quantity
=
random
.
getInt
(
10
,
100
);
String
dist01
=
random
.
getString
(
24
);
String
dist01
=
random
.
getString
(
24
);
...
@@ -421,9 +512,11 @@ public class BenchC implements Bench {
...
@@ -421,9 +512,11 @@ public class BenchC implements Bench {
private
void
loadDistrict
(
int
wId
)
throws
SQLException
{
private
void
loadDistrict
(
int
wId
)
throws
SQLException
{
BigDecimal
ytd
=
new
BigDecimal
(
"300000.00"
);
BigDecimal
ytd
=
new
BigDecimal
(
"300000.00"
);
int
nextId
=
3001
;
int
nextId
=
3001
;
PreparedStatement
prep
=
db
.
prepare
(
"INSERT INTO DISTRICT(D_ID, D_W_ID, D_NAME, "
PreparedStatement
prep
=
db
.
prepare
(
+
"D_STREET_1, D_STREET_2, D_CITY, D_STATE, D_ZIP, "
+
"D_TAX, D_YTD, D_NEXT_O_ID) "
"INSERT INTO DISTRICT(D_ID, D_W_ID, D_NAME, "
+
+
"VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
"D_STREET_1, D_STREET_2, D_CITY, D_STATE, D_ZIP, "
+
"D_TAX, D_YTD, D_NEXT_O_ID) "
+
"VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
);
for
(
int
dId
=
1
;
dId
<=
districtsPerWarehouse
;
dId
++)
{
for
(
int
dId
=
1
;
dId
<=
districtsPerWarehouse
;
dId
++)
{
String
name
=
random
.
getString
(
6
,
10
);
String
name
=
random
.
getString
(
6
,
10
);
String
[]
address
=
random
.
getAddress
();
String
[]
address
=
random
.
getAddress
();
...
...
h2/src/test/org/h2/test/bench/BenchCThread.java
浏览文件 @
e64ccfd2
...
@@ -131,14 +131,9 @@ public class BenchCThread {
...
@@ -131,14 +131,9 @@ public class BenchCThread {
int
oId
=
rs
.
getInt
(
1
)
-
1
;
int
oId
=
rs
.
getInt
(
1
)
-
1
;
BigDecimal
tax
=
rs
.
getBigDecimal
(
2
);
BigDecimal
tax
=
rs
.
getBigDecimal
(
2
);
rs
.
close
();
rs
.
close
();
// TODO optimizer: such cases can be optimized! A=1 AND B=A means
// also B=1!
// prep = prepare("SELECT C_DISCOUNT, C_LAST, C_CREDIT, W_TAX "
// + "FROM CUSTOMER, WAREHOUSE "
// + "WHERE C_ID=? AND W_ID=? AND C_W_ID=W_ID AND C_D_ID=?");
prep
=
prepare
(
"SELECT C_DISCOUNT, C_LAST, C_CREDIT, W_TAX "
prep
=
prepare
(
"SELECT C_DISCOUNT, C_LAST, C_CREDIT, W_TAX "
+
"FROM CUSTOMER, WAREHOUSE "
+
"FROM CUSTOMER, WAREHOUSE "
+
"WHERE C_ID=? AND
C_
W_ID=? AND C_W_ID=W_ID AND C_D_ID=?"
);
+
"WHERE C_ID=? AND W_ID=? AND C_W_ID=W_ID AND C_D_ID=?"
);
prep
.
setInt
(
1
,
cId
);
prep
.
setInt
(
1
,
cId
);
prep
.
setInt
(
2
,
warehouseId
);
prep
.
setInt
(
2
,
warehouseId
);
prep
.
setInt
(
3
,
dId
);
prep
.
setInt
(
3
,
dId
);
...
@@ -695,27 +690,21 @@ public class BenchCThread {
...
@@ -695,27 +690,21 @@ public class BenchCThread {
rs
.
next
();
rs
.
next
();
int
oId
=
rs
.
getInt
(
1
);
int
oId
=
rs
.
getInt
(
1
);
rs
.
close
();
rs
.
close
();
// prep = prepare("SELECT COUNT(DISTINCT S_I_ID) "
// + "FROM ORDER_LINE, STOCK WHERE OL_W_ID=? AND "
// + "OL_D_ID=? AND OL_O_ID<? AND "
// + "OL_O_ID>=?-20 AND S_W_ID=? AND "
// + "S_I_ID=OL_I_ID AND S_QUANTITY<?");
// prep.setInt(1, warehouseId);
// prep.setInt(2, d_id);
// prep.setInt(3, o_id);
// prep.setInt(4, o_id);
prep
=
prepare
(
"SELECT COUNT(DISTINCT S_I_ID) "
prep
=
prepare
(
"SELECT COUNT(DISTINCT S_I_ID) "
+
"FROM ORDER_LINE, STOCK WHERE OL_W_ID=? AND "
+
"FROM ORDER_LINE, STOCK WHERE "
+
"OL_D_ID=? AND OL_O_ID<? AND "
+
"OL_W_ID=? AND "
+
"OL_O_ID>=? AND S_W_ID=? AND "
+
"OL_D_ID=? AND "
+
"S_I_ID=OL_I_ID AND S_QUANTITY<?"
);
+
"OL_O_ID<? AND "
+
"OL_O_ID>=?-20 AND "
+
"S_W_ID=? AND "
+
"S_I_ID=OL_I_ID AND "
+
"S_QUANTITY<?"
);
prep
.
setInt
(
1
,
warehouseId
);
prep
.
setInt
(
1
,
warehouseId
);
prep
.
setInt
(
2
,
dId
);
prep
.
setInt
(
2
,
dId
);
prep
.
setInt
(
3
,
oId
);
prep
.
setInt
(
3
,
oId
);
prep
.
setInt
(
4
,
oId
-
20
);
prep
.
setInt
(
4
,
oId
);
prep
.
setInt
(
5
,
warehouseId
);
prep
.
setInt
(
5
,
warehouseId
);
prep
.
setInt
(
6
,
threshold
);
prep
.
setInt
(
6
,
threshold
);
// TODO this is where HSQLDB is very slow
rs
=
db
.
query
(
prep
);
rs
=
db
.
query
(
prep
);
rs
.
next
();
rs
.
next
();
// stockCount
// stockCount
...
...
h2/src/test/org/h2/test/bench/TestPerformance.java
浏览文件 @
e64ccfd2
...
@@ -19,6 +19,7 @@ import java.sql.Statement;
...
@@ -19,6 +19,7 @@ import java.sql.Statement;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Properties
;
import
java.util.Properties
;
import
org.h2.store.fs.FileSystem
;
import
org.h2.test.TestBase
;
import
org.h2.test.TestBase
;
import
org.h2.util.IOUtils
;
import
org.h2.util.IOUtils
;
import
org.h2.util.JdbcUtils
;
import
org.h2.util.JdbcUtils
;
...
@@ -53,15 +54,12 @@ public class TestPerformance {
...
@@ -53,15 +54,12 @@ public class TestPerformance {
return
DriverManager
.
getConnection
(
"jdbc:h2:data/results"
);
return
DriverManager
.
getConnection
(
"jdbc:h2:data/results"
);
}
}
private
void
openResults
(
boolean
init
)
throws
SQLException
{
private
void
openResults
()
throws
SQLException
{
Connection
conn
=
null
;
Connection
conn
=
null
;
Statement
stat
=
null
;
Statement
stat
=
null
;
try
{
try
{
conn
=
getResultConnection
();
conn
=
getResultConnection
();
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
if
(
init
)
{
stat
.
execute
(
"DROP TABLE IF EXISTS RESULTS"
);
}
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS RESULTS(TESTID INT, TEST VARCHAR, "
stat
.
execute
(
"CREATE TABLE IF NOT EXISTS RESULTS(TESTID INT, TEST VARCHAR, "
+
"UNIT VARCHAR, DBID INT, DB VARCHAR, RESULT VARCHAR)"
);
+
"UNIT VARCHAR, DBID INT, DB VARCHAR, RESULT VARCHAR)"
);
}
finally
{
}
finally
{
...
@@ -71,7 +69,6 @@ public class TestPerformance {
...
@@ -71,7 +69,6 @@ public class TestPerformance {
}
}
private
void
test
(
String
[]
args
)
throws
Exception
{
private
void
test
(
String
[]
args
)
throws
Exception
{
boolean
init
=
false
;
int
dbId
=
-
1
;
int
dbId
=
-
1
;
boolean
exit
=
false
;
boolean
exit
=
false
;
String
out
=
"benchmark.html"
;
String
out
=
"benchmark.html"
;
...
@@ -80,7 +77,7 @@ public class TestPerformance {
...
@@ -80,7 +77,7 @@ public class TestPerformance {
if
(
"-db"
.
equals
(
arg
))
{
if
(
"-db"
.
equals
(
arg
))
{
dbId
=
Integer
.
parseInt
(
args
[++
i
]);
dbId
=
Integer
.
parseInt
(
args
[++
i
]);
}
else
if
(
"-init"
.
equals
(
arg
))
{
}
else
if
(
"-init"
.
equals
(
arg
))
{
init
=
true
;
FileSystem
.
getInstance
(
"data"
).
deleteRecursive
(
"data"
)
;
}
else
if
(
"-out"
.
equals
(
arg
))
{
}
else
if
(
"-out"
.
equals
(
arg
))
{
out
=
args
[++
i
];
out
=
args
[++
i
];
}
else
if
(
"-trace"
.
equals
(
arg
))
{
}
else
if
(
"-trace"
.
equals
(
arg
))
{
...
@@ -127,7 +124,7 @@ public class TestPerformance {
...
@@ -127,7 +124,7 @@ public class TestPerformance {
Statement
stat
=
null
;
Statement
stat
=
null
;
PrintWriter
writer
=
null
;
PrintWriter
writer
=
null
;
try
{
try
{
openResults
(
init
);
openResults
();
conn
=
getResultConnection
();
conn
=
getResultConnection
();
stat
=
conn
.
createStatement
();
stat
=
conn
.
createStatement
();
prep
=
conn
prep
=
conn
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论