Batch update optimization

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying out batch update in Ado.Net.
SqlCommand cmd = new SqlCommand();
cmd.commandtext = "update...;update...'";
I put semicolon between each update.
I have thousand of records to update.
What would be an optimal number of updates to do in one statement?
 
Hi Arne,

Batching is already built in ado.net 2.
See SqlDataAdapter.UpdateBatchSize property...
If you are using .net 1.1. then you have to do it like you are doing it now
and the optimal batch size depends on several factors - if you need the
fastest solution then you should send as much updates at once as you can.
 
I don't have a datatable or dataset. I have an arraylist of data that needs
to be pushed to the database. Each item in the arraylist has two data items
that needs to make one new record.
Shall I add them to a datatable first?
--
Arne Garvander
(I program VB.Net for fun and C# to get paid.)


Miha Markic said:
Hi Arne,

Batching is already built in ado.net 2.
See SqlDataAdapter.UpdateBatchSize property...
If you are using .net 1.1. then you have to do it like you are doing it now
and the optimal batch size depends on several factors - if you need the
fastest solution then you should send as much updates at once as you can.
 
If you want to use ado.net 2.0 batching feature then yes, creata an
DataTable instance, configure adapter properly and there you go.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

Arne Garvander said:
I don't have a datatable or dataset. I have an arraylist of data that needs
to be pushed to the database. Each item in the arraylist has two data
items
that needs to make one new record.
Shall I add them to a datatable first?
--
Arne Garvander
(I program VB.Net for fun and C# to get paid.)


Miha Markic said:
Hi Arne,

Batching is already built in ado.net 2.
See SqlDataAdapter.UpdateBatchSize property...
If you are using .net 1.1. then you have to do it like you are doing it
now
and the optimal batch size depends on several factors - if you need the
fastest solution then you should send as much updates at once as you can.

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

message
I am trying out batch update in Ado.Net.
SqlCommand cmd = new SqlCommand();
cmd.commandtext = "update...;update...'";
I put semicolon between each update.
I have thousand of records to update.
What would be an optimal number of updates to do in one statement?
 
Back
Top