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

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -