c# - ADO.net SqlTransaction improves performance -
i'm doing work involves inserting batch of records sql database. size of batch vary arguments sake can 5000 records every 5 secs. less though. multiple processes writing table, nothing reading it.
what have noticed during quick test using sqltransaction around whole batch insert seems improve performance.
e.g.
sqltransaction trans = connection.begintransaction() mystoredproc.transaction = trans; sampledata.foreach(executenonqueryagainstdb); transaction.commit();
i'm not interested in having ability rollback changes wouldn't have considered using transaction except seems improve performance. if remove transaction code inserts go taking 300ms around 800ms!
what logic this? because understanding transaction still writes data db locks records until committed. have expected have overhead...
what looking fastest way insert.
if looking fast wqay insert/load data have @ sqlbulkcopy class
Comments
Post a Comment