Cool, thanks for your work.
Can you take measurements, then apply this patch to the test code, and
report on the difference?
On 2012-04-26 13:05, Carl Hasselskog wrote:
I've now created a patch for this (see attachment). Feel free to use
it under whatever license suits you.
When running then benchmark the difference was negligible. However,
after reading the benchmark code I couldn't find any part of that
actually would benefit from this patch (since all read are by
column-index not by name). Perhaps that it something that could be
added (e.g. by making queryReadResult read by column-name)? My guess
would be that getting by column-name would be more common so that
could potentially make the tests more similar to a real-world scenario.
Regards
Carl
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.
Index: src/test/org/h2/test/bench/BenchSimple.java
===================================================================
--- src/test/org/h2/test/bench/BenchSimple.java (revision 4205)
+++ src/test/org/h2/test/bench/BenchSimple.java (working copy)
@@ -62,7 +62,7 @@
prep = db.prepare("SELECT * FROM TEST WHERE ID=?");
for (int i = 0; i < records; i++) {
prep.setInt(1, random.nextInt(records));
- db.queryReadResult(prep);
+ db.queryReadResult(prep, new String[] { "ID", "NAME" });
}
db.end();
@@ -70,7 +70,7 @@
prep = db.prepare("SELECT * FROM TEST WHERE ID=?");
for (int i = 0; i < records; i++) {
prep.setInt(1, i);
- db.queryReadResult(prep);
+ db.queryReadResult(prep, new String[] { "ID", "NAME" });
}
db.end();
@@ -98,7 +98,7 @@
prep = db.prepare("SELECT * FROM TEST WHERE ID=?");
for (int i = 0; i < records; i++) {
prep.setInt(1, random.nextInt(records));
- db.queryReadResult(prep);
+ db.queryReadResult(prep, new String[] { "ID", "NAME" });
}
db.logMemory(this, "Memory Usage");
db.closeConnection();
Index: src/test/org/h2/test/bench/Database.java
===================================================================
--- src/test/org/h2/test/bench/Database.java (revision 4205)
+++ src/test/org/h2/test/bench/Database.java (working copy)
@@ -442,6 +442,20 @@
}
}
}
+
+ /**
+ * Execute a query and read all rows.
+ *
+ * @param prep the prepared statement
+ */
+ void queryReadResult(PreparedStatement prep, String[] columnNames) throws
SQLException {
+ ResultSet rs = prep.executeQuery();
+ while (rs.next()) {
+ for (int i = 0; i < columnNames.length; i++) {
+ rs.getString(columnNames[i]);
+ }
+ }
+ }
/**
* Get the number of executed statements.