Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9017335
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:14:51+00:00 2026-06-16T04:14:51+00:00

I wonder how SqlDataAdapter works internally, especially when using UpdateCommand for updating a huge

  • 0

I wonder how SqlDataAdapter works internally, especially when using UpdateCommand for updating a huge DataTable (since it’s usually a lot faster that just sending sql statements from a loop).

Here is some idea I have in mind :

  • It creates a prepared sql statement (using SqlCommand.Prepare()) with CommandText filled and sql parameters initialized with correct sql types. Then, it loops on datarows that need to be updated, and for each record, it updates parameters values, and call SqlCommand.ExecuteNonQuery().
  • It creates a bunch of SqlCommand objects with everything filled inside (CommandText and sql parameters). Several SqlCommands at once are then batched to the server (depending of UpdateBatchSize).
  • It uses some special, low level or undocumented sql driver instructions that allow to perform an update on several rows in a effecient way (rows to update would need to be provided using a special data format and a the same sql query (UpdateCommand here) would be executed against each of these rows).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T04:14:52+00:00Added an answer on June 16, 2026 at 4:14 am

    It uses an internal facility of the SQL Server client classes which is called command sets. You can send multiple batches with a single command to SQL Server. This cuts down on per-call overhead. You have less server roundtrips and such.

    A single row is updated per statement, and one statement per batch is sent, but multiple batches per roundtrip are send. The last point in this list is the magic sauce.

    Unfortunately, this facility is not publicly exposed. Ayende took a hack on this and built a private-reflection bases API for it.

    If you want more information I encourage you to look at the internal SqlCommandSet class.

    That said, you can go faster than this by yourself: Transfer the update data using a TVP and issue a single UPDATE that updates many rows. That way you save all per-batch, per-roundtrip and per-statement overheads.

    Such a query would look like this:

    update T set T.x = @src.x from T join @src on T.ID = @src.ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder about that can I write native SQL to add or delete operations
I wonder, using Eclipse's PyDev plugin , how come documentation does not always show
using (IDbCommand command = new SqlCommand()) { IDbDataAdapter adapter = new SqlDataAdapter(); DataSet ds
I wonder yii works with cassandra. If anybody know how it work. Please post
I wonder what is the overhead of getting the messages one by one using
I wonder what's the best approach for using third party js libraries on a
I wonder what I should be carefull of updating PHP on Windows(with Apache). My
I wonder if that hurts performance. I have an test app which is pretty
I wonder if there is any optimization I can do to achieve faster SELECTs
I wonder how weak references work internally, for example in .NET or in Java.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.