1

I want to insert data into Database from C#. Below are the two ways I am trying.

  • Using Stored Procedure - In this I have insert statement. Calling this stored procedure from C# by passing parameters.
  • Using LINQ - In this, I am using Data Context, with that I will get table and calling InsertOnSubmit method by passing required parameter.

I am able to insert in both the ways. Right now we have less data so not able to judge which is better. And this Insertion will happen for millions of data. I will be calling this stored procedure or LINQ InsertOnSubmit for those many times.

Can anyone Suggest which of this method will be faster? Do we have any other way which is better than these also will be fine.

Thanks in Advance.

trinadh
  • 258
  • 4
  • 14

1 Answers1

2

If you are inserting in same time those millions of rows, you should create fever but bigger bunches of data to be inserted with minimun amount of database transactions. Millions of rows with one-by-one insertions is slow in any case.

Bulk operations can be implemented for example following ways:

Risto M
  • 2,919
  • 1
  • 14
  • 27
  • 1
    Thanks for great information. This will really help me to improve my way of thinking for this problem. – trinadh Jan 31 '18 at 07:12
  • Happy to help! It is good to hear that you are thinking performance issues in early phase of your project. Sometimes those questions arise too late. – Risto M Jan 31 '18 at 07:17