Why are batch inserts so slow in H2 with JDBC driver (5 sec for 1000 records)?

204 views
Skip to first unread message

Bill

unread,
Apr 3, 2012, 5:02:55 PM4/3/12
to h2-da...@googlegroups.com
I've got a snippet of java code which inserts 1000 records in java using a prepared statement.  Here are some times I observed for my 'executeBatch()' line of code:
 
234 ms on SQL SERVER (remote workstation, 2-7ms ping time)
4712 ms on H2 (remote workstation, 2-7ms ping time)
244 ms on H2 (close workstation, same switch)
 
It seems the H2 driver is sensitive to network latency.  Is this because of an inefficiency in the driver or is there a parameter I need to set somewhere?  I've tried with Oracle as well and it is as fast as SQL SERVER from the remote workstation.
 
Thanks for any tips.  As far as I can tell, I have a current JDBC driver for H2 (v 1.3.154 built on 4/4/2011)
Bill
 

Noel Grandin

unread,
Apr 4, 2012, 3:57:12 AM4/4/12
to h2-da...@googlegroups.com, Bill
If you're talking about the addBatch() etc. methods in the JDBC
interface, then it looks like H2 doesn't have support for making those
efficient across network connections.

If you'd like to start hacking, the place to start is the code in the class
org.h2.engine.SessionRemote
:-)

> --
> You received this message because you are subscribed to the Google
> Groups "H2 Database" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/h2-database/-/dK9WiY1rr_0J.
> To post to this group, send email to h2-da...@googlegroups.com.
> To unsubscribe from this group, send email to
> h2-database...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/h2-database?hl=en.

Reply all
Reply to author
Forward
0 new messages