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

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

上级 5dbcd675
......@@ -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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论