473,396 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Best Practice for Uploading to SQL Server?

Hi there,

I have an ArrayList containing approximately 20,000 database INSERT
command objects. Each of these commands needs to be executed. The commands
do not need to be executed in any particular order, nor do they need to be
part of a transaction.

I'm currently accomplishing this task by iterating through the ArrayList
via the foreach construct and Executing each command. This works fine but
I'm wondering if there's a way to get the upload to execute faster. Here's
why I ask: During the upload:

- The CPU useage on the uploader machine is very low.
- The CPU useage on the database machine is very low.
- The network bandwidth between machines isn't saturated.

Since neither computer is even breathing hard during this operation, it
leads me to believe that there is room for optimization. Here's one approach
that I'm considering:

Store the commands in a Queue instead of an ArrayList. Spawn multiple
threads. Each thread attempts to pop a command off the Queue and execute it
using its own database connection. The threads will keep working until the
Queue is empty. Am I on the right track? If so, how many threads should I
spawn?

I feel like there should be a way to speed up my upload but I'm not
sure how to proceed. I know that there is a program called BCC designed for
this sort of thing, but in my case, I want everything to be done in my C#
app instead of shelling out to another app.

Thanks,

The Oracle
Nov 17 '05 #1
1 1242
Hi,

Yes, you could do it in a batch if you send your content into stored
procedure as XML string and process it there. Here are some examples how to
do this

http://support.microsoft.com/default...b;en-us;316244

http://support.microsoft.com/default...b;en-us;555266

--
Val Mazur
Microsoft MVP

http://xport.mvps.org

"The Oracle" <9t******@Building502.TheMatrix.com> wrote in message
news:8o********************@giganews.com...
Hi there,

I have an ArrayList containing approximately 20,000 database INSERT
command objects. Each of these commands needs to be executed. The commands
do not need to be executed in any particular order, nor do they need to be
part of a transaction.

I'm currently accomplishing this task by iterating through the
ArrayList via the foreach construct and Executing each command. This works
fine but I'm wondering if there's a way to get the upload to execute
faster. Here's why I ask: During the upload:

- The CPU useage on the uploader machine is very low.
- The CPU useage on the database machine is very low.
- The network bandwidth between machines isn't saturated.

Since neither computer is even breathing hard during this operation, it
leads me to believe that there is room for optimization. Here's one
approach that I'm considering:

Store the commands in a Queue instead of an ArrayList. Spawn multiple
threads. Each thread attempts to pop a command off the Queue and execute
it using its own database connection. The threads will keep working until
the Queue is empty. Am I on the right track? If so, how many threads
should I spawn?

I feel like there should be a way to speed up my upload but I'm not
sure how to proceed. I know that there is a program called BCC designed
for this sort of thing, but in my case, I want everything to be done in my
C# app instead of shelling out to another app.

Thanks,

The Oracle

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
10
by: Rich Wallace | last post by:
Hey all, I have an XML doc that I read into a SQL Server database from an integration feed.... ----------------XML snippet ---------------- <?xml version="1.0" encoding="us-ascii"?>...
13
by: Sky Sigal | last post by:
I have created an IHttpHandler that waits for uploads as attachments for a webmail interface, and saves it to a directory that is defined in config.xml. My question is the following: assuming...
20
by: Keith G. Murphy | last post by:
I'm trying to get a feel for what most people are doing or consider best practice. Given a mod_perl application talking to a PostgreSQL database on the same host, where different users are...
1
by: MichaelG | last post by:
I have a web service that talks to SQL Server 2005. At present the WS uses an SQL Server login and password to connect. Is this best practice or should I be running the WS under a domain account...
3
by: Marc Gravell | last post by:
Kind of an open question on best-practice for smart-client design. I'd really appreciate anyones views (preferably with reasoning, but I'll take what I get...). Or if anybody has any useful links...
4
by: Ned Balzer | last post by:
Hi all, I am pretty new to asp.net; I've done lots of classic asp, but am just beginning to get my mind wrapped around .net. What I'd like to do is include some code that tests if a user is...
2
yashg
by: yashg | last post by:
I am building a data backup application in C# using Sockets. It has a server component and a client component. The client is going to upload files to the server through TCP sockets. I've got all...
3
by: Venkat | last post by:
Hi, We have a windows application developed in c# and SQL Server 2005. Our application need to execute more than one command (ExecuteReader and ExecuteScalar) at a single time. Till now we have...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.