提交 e64ccfd2 authored 作者: Thomas Mueller's avatar Thomas Mueller

Delete old databases before testing; small formatting changes; use standard statements.

上级 5dbcd675
......@@ -24,69 +24,145 @@ public class BenchC implements Bench {
private static final String[] TABLES = new String[] { "WAREHOUSE", "DISTRICT", "CUSTOMER", "HISTORY", "ORDERS",
"NEW_ORDER", "ITEM", "STOCK", "ORDER_LINE", "RESULTS" };
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"
+ " W_STREET_1 VARCHAR(20),\n" + " W_STREET_2 VARCHAR(20),\n" + " W_CITY VARCHAR(20),\n"
+ " W_STATE CHAR(2),\n" + " W_ZIP CHAR(9),\n" + " 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))",
"CREATE TABLE WAREHOUSE(\n" +
" W_ID INT NOT NULL PRIMARY KEY,\n" +
" W_NAME VARCHAR(10),\n" +
" W_STREET_1 VARCHAR(20),\n" +
" W_STREET_2 VARCHAR(20),\n" +
" W_CITY VARCHAR(20),\n" +
" W_STATE CHAR(2),\n" +
" W_ZIP CHAR(9),\n" +
" 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"
// + " REFERENCES WAREHOUSE(W_ID))",
"CREATE TABLE CUSTOMER(\n" + " C_ID INT NOT NULL,\n" + " C_D_ID INT NOT NULL,\n"
+ " C_W_ID INT NOT NULL,\n" + " C_FIRST VARCHAR(16),\n" + " C_MIDDLE CHAR(2),\n"
+ " C_LAST VARCHAR(16),\n" + " C_STREET_1 VARCHAR(20),\n" + " 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))",
"CREATE TABLE CUSTOMER(\n" +
" C_ID INT NOT NULL,\n" +
" C_D_ID INT NOT NULL,\n" +
" C_W_ID INT NOT NULL,\n" +
" C_FIRST VARCHAR(16),\n" +
" C_MIDDLE CHAR(2),\n" +
" C_LAST VARCHAR(16),\n" +
" C_STREET_1 VARCHAR(20),\n" +
" 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"
// + " REFERENCES DISTRICT(D_W_ID, D_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"
+ " H_W_ID INT,\n" + " H_DATE TIMESTAMP,\n" + " H_AMOUNT DECIMAL(6, 2),\n" + " H_DATA VARCHAR(24))",
"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" +
" 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"
// + " REFERENCES CUSTOMER(C_W_ID, C_D_ID, C_ID),\n"
// + " FOREIGN KEY(H_W_ID, H_D_ID)\n"
// + " 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"
+ " 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))",
"CREATE TABLE ORDERS(\n" +
" O_ID INT NOT NULL,\n" +
" 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"
// + " REFERENCES CUSTOMER(C_W_ID, C_D_ID, C_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"
+ " NO_W_ID INT NOT NULL,\n" + " PRIMARY KEY(NO_W_ID, NO_D_ID, NO_O_ID))",
"CREATE TABLE NEW_ORDER(\n" +
" 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"
// + " 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"
+ " I_PRICE DECIMAL(5, 2),\n" + " I_DATA VARCHAR(50),\n" + " PRIMARY KEY(I_ID))",
"CREATE TABLE STOCK(\n" + " 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))",
"CREATE TABLE ITEM(\n" +
" I_ID INT NOT NULL,\n" +
" I_IM_ID INT,\n" +
" I_NAME VARCHAR(24),\n" +
" I_PRICE DECIMAL(5, 2),\n" +
" I_DATA VARCHAR(50),\n" +
" PRIMARY KEY(I_ID))",
"CREATE TABLE STOCK(\n" +
" 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"
// + " REFERENCES WAREHOUSE(W_ID),\n"
// + " 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"
+ " OL_W_ID INT NOT NULL,\n" + " 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))",
"CREATE TABLE ORDER_LINE(\n" +
" OL_O_ID INT NOT NULL,\n" +
" OL_D_ID INT NOT NULL,\n" +
" OL_W_ID INT NOT NULL,\n" +
" 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"
// + " REFERENCES ORDER(O_W_ID, O_D_ID, O_ID),\n"
// + " FOREIGN KEY(OL_SUPPLY_W_ID, OL_I_ID)\n"
// + " 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"
+ " RESPONSE_TIME INT,\n" + " PROCESSING_TIME INT,\n" + " KEYING_TIME INT,\n"
+ " THINK_TIME INT,\n" + " SUCCESSFUL INT,\n" + " NOW TIMESTAMP)" };
"CREATE TABLE RESULTS(\n" +
" ID INT NOT NULL PRIMARY KEY,\n" +
" 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 items = 10000;
......@@ -155,8 +231,9 @@ public class BenchC implements Bench {
private void loadItem() throws SQLException {
trace("Loading item table");
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) "
+ "VALUES(?, ?, ?, ?, ?)");
PreparedStatement prep = db.prepare(
"INSERT INTO ITEM(I_ID, I_IM_ID, I_NAME, I_PRICE, I_DATA) " +
"VALUES(?, ?, ?, ?, ?)");
for (int id = 1; id <= items; id++) {
String name = random.getString(14, 24);
BigDecimal price = random.getBigDecimal(random.getInt(100, 10000), 2);
......@@ -179,8 +256,10 @@ public class BenchC implements Bench {
private void loadWarehouse() throws SQLException {
trace("Loading warehouse table");
PreparedStatement prep = db.prepare("INSERT INTO WAREHOUSE(W_ID, W_NAME, W_STREET_1, "
+ "W_STREET_2, W_CITY, W_STATE, W_ZIP, W_TAX, W_YTD) " + "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)");
PreparedStatement prep = db.prepare(
"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++) {
String name = random.getString(6, 10);
String[] address = random.getAddress();
......@@ -226,13 +305,18 @@ public class BenchC implements Bench {
private void loadCustomerSub(int dId, int wId) throws SQLException {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
PreparedStatement prepCustomer = db.prepare("INSERT INTO CUSTOMER(C_ID, C_D_ID, C_W_ID, "
+ "C_FIRST, C_MIDDLE, C_LAST, " + "C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, "
+ "C_PHONE, C_SINCE, C_CREDIT, " + "C_CREDIT_LIM, C_DISCOUNT, C_BALANCE, C_DATA, "
+ "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 (?, ?, ?, ?, ?, ?, ?, ?)");
PreparedStatement prepCustomer = db.prepare(
"INSERT INTO CUSTOMER(C_ID, C_D_ID, C_W_ID, " +
"C_FIRST, C_MIDDLE, C_LAST, " +
"C_STREET_1, C_STREET_2, C_CITY, C_STATE, C_ZIP, " +
"C_PHONE, C_SINCE, C_CREDIT, " +
"C_CREDIT_LIM, C_DISCOUNT, C_BALANCE, C_DATA, " +
"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++) {
String first = random.getString(8, 16);
String middle = "OE";
......@@ -313,13 +397,19 @@ public class BenchC implements Bench {
private void loadOrderSub(int dId, int wId) throws SQLException {
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
int[] orderid = random.getPermutation(ordersPerDistrict);
PreparedStatement prepOrder = db.prepare("INSERT INTO ORDERS(O_ID, O_C_ID, O_D_ID, O_W_ID, "
+ "O_ENTRY_D, O_CARRIER_ID, O_OL_CNT, O_ALL_LOCAL) " + "VALUES(?, ?, ?, ?, ?, ?, ?, 1)");
PreparedStatement prepNewOrder = db.prepare("INSERT INTO NEW_ORDER (NO_O_ID, NO_D_ID, NO_W_ID) "
+ "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)");
PreparedStatement prepOrder = db.prepare(
"INSERT INTO ORDERS(O_ID, O_C_ID, O_D_ID, O_W_ID, " +
"O_ENTRY_D, O_CARRIER_ID, O_OL_CNT, O_ALL_LOCAL) " +
"VALUES(?, ?, ?, ?, ?, ?, ?, 1)");
PreparedStatement prepNewOrder = db.prepare(
"INSERT INTO NEW_ORDER (NO_O_ID, NO_D_ID, NO_W_ID) " +
"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++) {
int cId = orderid[oId - 1];
int carrierId = random.getInt(1, 10);
......@@ -372,11 +462,12 @@ public class BenchC implements Bench {
private void loadStock(int wId) throws SQLException {
trace("Loading stock table (warehouse " + wId + ")");
boolean[] original = random.getBoolean(items, items / 10);
PreparedStatement prep = db.prepare("INSERT INTO STOCK(S_I_ID, S_W_ID, S_QUANTITY, "
+ "S_DIST_01, S_DIST_02, S_DIST_03, S_DIST_04, S_DIST_05, "
+ "S_DIST_06, S_DIST_07, S_DIST_08, S_DIST_09, S_DIST_10, "
+ "S_DATA, S_YTD, S_ORDER_CNT, S_REMOTE_CNT) "
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PreparedStatement prep = db.prepare(
"INSERT INTO STOCK(S_I_ID, S_W_ID, S_QUANTITY, " +
"S_DIST_01, S_DIST_02, S_DIST_03, S_DIST_04, S_DIST_05, " +
"S_DIST_06, S_DIST_07, S_DIST_08, S_DIST_09, S_DIST_10, " +
"S_DATA, S_YTD, S_ORDER_CNT, S_REMOTE_CNT) " +
"VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
for (int id = 1; id <= items; id++) {
int quantity = random.getInt(10, 100);
String dist01 = random.getString(24);
......@@ -421,9 +512,11 @@ public class BenchC implements Bench {
private void loadDistrict(int wId) throws SQLException {
BigDecimal ytd = new BigDecimal("300000.00");
int nextId = 3001;
PreparedStatement prep = db.prepare("INSERT INTO DISTRICT(D_ID, D_W_ID, D_NAME, "
+ "D_STREET_1, D_STREET_2, D_CITY, D_STATE, D_ZIP, " + "D_TAX, D_YTD, D_NEXT_O_ID) "
+ "VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
PreparedStatement prep = db.prepare(
"INSERT INTO DISTRICT(D_ID, D_W_ID, D_NAME, " +
"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++) {
String name = random.getString(6, 10);
String[] address = random.getAddress();
......
......@@ -131,14 +131,9 @@ public class BenchCThread {
int oId = rs.getInt(1) - 1;
BigDecimal tax = rs.getBigDecimal(2);
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 "
+ "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(2, warehouseId);
prep.setInt(3, dId);
......@@ -695,27 +690,21 @@ public class BenchCThread {
rs.next();
int oId = rs.getInt(1);
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) "
+ "FROM ORDER_LINE, STOCK WHERE OL_W_ID=? AND "
+ "OL_D_ID=? AND OL_O_ID<? AND "
+ "OL_O_ID>=? AND S_W_ID=? AND "
+ "S_I_ID=OL_I_ID AND S_QUANTITY<?");
+ "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, dId);
prep.setInt(3, oId);
prep.setInt(4, oId - 20);
prep.setInt(4, oId);
prep.setInt(5, warehouseId);
prep.setInt(6, threshold);
// TODO this is where HSQLDB is very slow
rs = db.query(prep);
rs.next();
// stockCount
......
......@@ -19,6 +19,7 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.Properties;
import org.h2.store.fs.FileSystem;
import org.h2.test.TestBase;
import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils;
......@@ -53,15 +54,12 @@ public class TestPerformance {
return DriverManager.getConnection("jdbc:h2:data/results");
}
private void openResults(boolean init) throws SQLException {
private void openResults() throws SQLException {
Connection conn = null;
Statement stat = null;
try {
conn = getResultConnection();
stat = conn.createStatement();
if (init) {
stat.execute("DROP TABLE IF EXISTS RESULTS");
}
stat.execute("CREATE TABLE IF NOT EXISTS RESULTS(TESTID INT, TEST VARCHAR, "
+ "UNIT VARCHAR, DBID INT, DB VARCHAR, RESULT VARCHAR)");
} finally {
......@@ -71,7 +69,6 @@ public class TestPerformance {
}
private void test(String[] args) throws Exception {
boolean init = false;
int dbId = -1;
boolean exit = false;
String out = "benchmark.html";
......@@ -80,7 +77,7 @@ public class TestPerformance {
if ("-db".equals(arg)) {
dbId = Integer.parseInt(args[++i]);
} else if ("-init".equals(arg)) {
init = true;
FileSystem.getInstance("data").deleteRecursive("data");
} else if ("-out".equals(arg)) {
out = args[++i];
} else if ("-trace".equals(arg)) {
......@@ -127,7 +124,7 @@ public class TestPerformance {
Statement stat = null;
PrintWriter writer = null;
try {
openResults(init);
openResults();
conn = getResultConnection();
stat = conn.createStatement();
prep = conn
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论