java - Batch inserts in JDBC - how much slower will a single transaction be? -


i found out jdbc's addbatch operation, if given "insert mytable (id, name) values (?, ?)" create this:

begin transaction insert mytable (id, name) values (1, "a");  insert mytable (id, name) values (2, "b"); ... end transaction  

compared statement this: "insert mytable (id, name) values (1, "a"), (2, "b"), .. ", how slower massive transaction be? difference in i/o matter significantly?

pgjdbc batching not fast multi-valued insert, is more convenient.

by far efficient option use copy command via pgjdbc's support copy.

a second option open transaction, batches of multi-valued inserts of (say) 10 rows per insert, followed set of single-row inserts make difference , commit.

pgjdbc batching should not faster opening transaction, preparing statement, looping on data sending each row prepared statement, doing explicit commit. don't think has multiple statements in-flight @ once in batch, i'm not sure of , if make batches faster when network latency factor.

i'd suggest testing out , getting practical idea of impact.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -