java - MS SQL Bulk update\insert -
some time ago faced problem of bulk insert\update ms sql database.
task pretty simple - retrieve data db, perform data transformation , update parent table , fill out child table. volume of data huge, that's why interested in performant way this. in db (stored procedures, file processing, etc) not applicable, since need piece of information third-party application.
although in internet can find lot of articles of how disable autocommit , perform batch inserts\updates, anyway send requests one-by-one. applicable majority free jdbc drivers, including popular 1 - net.sourceforge.jtds.jdbc.driver (http://sourceforge.net/p/jtds/discussion/129584/thread/8e89906c/). datadirect supports such functionality, it's not free. fiy - list of jdbc drivers sql server 2008 (comparison).
please share experience in solving similar problems.
best regards,
alex
we solved problem in other way. since need perform 2 pieces of data modification (insert new child record , update existing parent fields) in bulk rewrote queries this:
update:
update parenttable set deviceinformation = dual.deviceinformation parenttable ptb join ( values (1, 'info1'), (2, 'info2')) dual (parenttableid, deviceinformation) on ptb.parenttableid = dual.parenttableid
the same idea insert:
insert dbo.childtable (childid, childnumber, info) values (1, 1, 'some text'), (2, 2, 'some text2')
it gave significant performance improvement, since of time spent on connection establishment.
i hope helpful.
Comments
Post a Comment