BIRT 3.7
Written by: Michael Williams
Featured Refcardz: Top Refcardz:
  1. Scrum
  2. Apache Maven 2
  3. Essential MySQL
  4. Node.js
  5. Groovy
  1. jQuery Selectors
  2. Ajax
  3. Java
  4. Spring Config.
  5. Java Concurrency

Link Details

You pick the winners! Login and vote now.
Link 74856 thumbnail
User 270032 avatar

By coderbaby
via codicesoftware.blogspot.com
Published: Apr 10 2008 / 09:21

Which is the fastest way to insert 100K records using C#? The post compares three different ways using MySql, SQL Server and Firebird.
  • 8
  • 2
  • 4659
  • 12

Comments

Add your comment
User 111696 avatar

bloid replied ago:

0 votes Vote down Vote up Reply

100K registers?!? I guess they mean records...

And seems to be doing it by concatenating strings into SQL statements, which I would have thought was a very bad way of doing it...

What's wrong with a prepared statement in batch mode?

User 270032 avatar

coderbaby replied ago:

0 votes Vote down Vote up Reply

Yes, records.

String concat is only done in MySql... which seems to be the fastest way (and faster than firebird and sqlserver)

Prepared statements like in Java? Because a prepare actually happens after the first call. Can you send some links in C#? I don't find an equivalent to executeBatch

User 111696 avatar

bloid replied ago:

0 votes Vote down Vote up Reply

Sorry, yeah I meant using a SqlDataAdapter and transactional control to commit after a "batch" of inserts had been done

My comment was when my head was in "java mode" (I've been doing Perl all morning, and it scrambled my brain) ;-)

User 270032 avatar

coderbaby replied ago:

0 votes Vote down Vote up Reply

Thanks bloid.

Yes, I've seem samples in Perl and Java, but not in C#.

Do you think a SqlDataAdapter will be faster than directly issuing commands with a IDbCommand inside a transaction?

I'll check.


User 282366 avatar

ScaleOvenStove replied ago:

3 votes Vote down Vote up Reply

this article really doesnt explore all the options. I got 1 million records to insert in 17 seconds with SqlBulkCopy...

http://blog.stevienova.com/2008/01/16/net-fastest-way-to-load-text-file-to-sql-sqlbulkcopy/


,

User 247528 avatar

dengar007 replied ago:

1 votes Vote down Vote up Reply

Bulk Copy is WAY faster.

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (8)



Voters Against This Link (2)