Re: Connection object question
- From: Edward Diener <eddielee_no_spam_here@xxxxxxxxxxxxxx>
- Date: Sat, 28 May 2005 18:38:54 -0400
William (Bill) Vaughn wrote:
The fastest way to perform an update is to do so on the server. If you're changing existing rows from an external source I suggest moving the changes (in the form of rows) to the server first. Next, execute a server-side UPDATE that pulls the changes out of the imported table and applies the changes.
Why would moving all the data to the server in the form of an imported table and then executing an UPDATE ( or INSERT ) on the server be any faster than executing an UPDATE ( or INSERT ) for each row from the client to the server ? Either way the data must be moved across the line from the client to the server. In your first way, it all gets moved at once. In the second, row by row way, it gets moved with each row.
The one advantage of your way that I see is that by moving all the rows to the server immediately at once, the logic to decide on an UPDATE or an INSERT can be encapsulated on the server. Whereas using the row by row way, I may need to first try an UPDATE based on a key and, if that fails, do an INSERT and that might take two trips from client to server just to process a row. In my actual case, most of the work is just INSERTs so this will save little time, but in areas where UPDATEs based on keys are prevalent, your method might work better.
Is there any other advantage of your method ?
Moving the data to the server is accomplished with DTC or BCP. In ADO 2.0 you'll be able to use the new SqlClient BulkCopy class--far easier. I just wrote a program that imports 450,000 rows into SQL Server--it took about 30 seconds.
I will look into bulk copying. Thanks !
I'll be showing attendees at the DevTeach conference how to do this in my ADO.NET workshop (see my web site for details).
What is the address of your website ? .
- Follow-Ups:
- Re: Connection object question
- From: news.microsoft.com
- Re: Connection object question
- From: Stephen Howe
- Re: Connection object question
- References:
- Connection object question
- From: Edward Diener
- Re: Connection object question
- From: Mark J. McGinty
- Re: Connection object question
- From: Edward Diener
- Re: Connection object question
- From: Stephen Howe
- Re: Connection object question
- From: Edward Diener
- Re: Connection object question
- From: Stephen Howe
- Re: Connection object question
- From: Edward Diener
- Re: Connection object question
- From: William \(Bill\) Vaughn
- Connection object question
- Prev by Date: SQLSummit.com catalog of drivers and data providers (ODBC, OLE DB, .NET, etc.)
- Next by Date: Read from one, write into another data source
- Previous by thread: Re: Connection object question
- Next by thread: Re: Connection object question
- Index(es):
Relevant Pages
|
|