Sep 28, 2005
[Derby] Derby の実行速度
Derby の INSERT 速度を試してみた。 時間がなかったのでかなりいい加減。 非常に単純な INSERT 文を 100 万回繰り返してみた。
結果
| embedded モード | server モード | |
|
INSERT 1000000回 コネクション毎に 1000000 件ずつ 1 回繰り返し |
45406msec (≒45秒) | 320594msec (≒5分) |
|
INSERT 1000000回 コネクション毎に 1000 件ずつ 1000 回繰り返し |
51797msec (≒52秒) | 321812msec (≒5分) |
|
INSERT 1000000回 コネクション毎に 1 件ずつ 1000000 回繰り返し |
798422msec (≒13分) | 計測不能(何故か Exception で落ちる) |
環境
- OS
- Windows XP Professional
- CPU
- Pentium4 2.4GHz
- Memory
- 1GByte
コード(部分抜粋)
protected void insertRecordMassively1() throws SQLException {
// 1 回のコネクションで 1000 件の INSERT を 1000 回繰り返す。
long start = System.currentTimeMillis();
for (int i = 0; i < 1000; i++) {
Connection connection = this.getConnection();
try {
PreparedStatement statement = connection
.prepareStatement("INSERT INTO sample VALUES (?,?)");
for (int j = 0; j < 1000; j++) {
int field01 = (int) ((Math.random() * 100000) % 10000);
String field02 = "01:" + field01;
statement.setInt(1, field01);
statement.setString(2, field02);
statement.executeUpdate();
}
connection.commit();
connection.close();
} finally {
if (connection != null) {
connection.close();
}
}
}
long end = System.currentTimeMillis();
System.out.println("INSERT * 1000 * 1000 : " + (end - start) + "msec");
}



