473,399 Members | 4,177 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,399 software developers and data experts.

Performance when using paramterised queries

Hi all

SQL Server 2000 & C# 2005

Currently if I want to execute a batch of INSERT's I will join all the inserts
up with ; and then execute them at once in one execution, however I am considering
the use of parameterised queries - I'm wondering if there is any major performance
issues here, say I have 100 INSERT's, now I've got 100 individual Command
objects.

Any ideas? I would've thought it's not going to hit massively but I wanted
some in-sight into how SQL/.Net would handle a transaction of around 100
commands.

Thanks
Kev
Feb 14 '06 #1
2 1199
Kevin,

See inline:
SQL Server 2000 & C# 2005

Currently if I want to execute a batch of INSERT's I will join all the
inserts up with ; and then execute them at once in one execution,
There is no reason to do this. The SqlDataAdapter will do this for you,
and you don't have to string all of those statements together, worrying
about the upper limit (the number of parameters that can be passed in one
shot).

For more information on how to enable batch processing, see the section
of the framework documentation titled "Performing Batch Updates with a
DataAdapter", located at (watch for line wrap):

http://msdn2.microsoft.com/en-us/library/kbbwt18a.aspx
however I am considering the use of parameterised queries - I'm wondering
if there is any major performance issues here, say I have 100 INSERT's,
now I've got 100 individual Command objects.
Why will you have 100 different command objects? Unless you are
targeting 100 different tables, you should be able to factor it down to a
few queries and parameterize them.
Any ideas? I would've thought it's not going to hit massively but I
wanted some in-sight into how SQL/.Net would handle a transaction of
around 100 commands.
Well, it depends on the nature of the work that you are doing. If it is
imply inserts updates and deletes that are not too complex, then it should
be able to handle this just fine.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

Thanks
Kev

Feb 14 '06 #2
> Kevin,

See inline:
SQL Server 2000 & C# 2005

Currently if I want to execute a batch of INSERT's I will join all
the inserts up with ; and then execute them at once in one execution,

There is no reason to do this. The SqlDataAdapter will do this
for you, and you don't have to string all of those statements
together, worrying about the upper limit (the number of parameters
that can be passed in one shot).

For more information on how to enable batch processing, see the
section of the framework documentation titled "Performing Batch
Updates with a DataAdapter", located at (watch for line wrap):

http://msdn2.microsoft.com/en-us/library/kbbwt18a.aspx
however I am considering the use of parameterised queries - I'm
wondering if there is any major performance issues here, say I have
100 INSERT's, now I've got 100 individual Command objects.

Why will you have 100 different command objects? Unless you are
targeting 100 different tables, you should be able to factor it down
to a few queries and parameterize them.
Any ideas? I would've thought it's not going to hit massively but I
wanted some in-sight into how SQL/.Net would handle a transaction of
around 100 commands.

Well, it depends on the nature of the work that you are doing. If
it is imply inserts updates and deletes that are not too complex, then
it should be able to handle this just fine.


We are building a framework and basically we are using Businessobjects that
are completely disconnected from the database, we have a data layer that
updates the database from the businessobjects, there could be a 100 [different]
types of businessobject in an array that is sent to the data layer, it then
constructs all of the SQL statements and sends the lot off to SQL Server
in one big concatenation of sql strings.

What I want to do is convert this behaviour of constructing SQL strings to
use parameterised queries instead - the only thing is I need to be sure that
a) it's a good idea, b) there is no performance hit and c) it isn't going
to be more hassle than it's worth.

HTMS

Kev
Feb 15 '06 #3

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

Similar topics

17
by: lkrubner | last post by:
I've got a PHP application that's 2 megs in size. Of that, my guess is 200k-400k is comments. Do they impose a performance hit? I've been postponing any kind of optimization, but at some point I'll...
3
by: Andy Tran | last post by:
I built a system using mysql innodb to archive SMS messages but the innodb databases are not keeping up with the number of SMS messages coming in. I'm looking for performance of 200 msgs/sec where...
6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
12
by: serge | last post by:
I have an SP that is big, huge, 700-800 lines. I am not an expert but I need to figure out every possible way that I can improve the performance speed of this SP. In the next couple of weeks I...
15
by: alex4groups | last post by:
Hi, I've been creating a db application using MS Access and MSDE. Only two of us are using the application, and the server and the app both run great on my laptop (1.6 GHz Pentium M, 2GB RAM,...
5
by: charlies224 | last post by:
Hi, I am using SQL 2000 and has a table that contains more than 2 million rows of data (and growing). Right now, I have encountered 2 problems: 1) Sometimes, when I try to query against this...
4
by: Bob Alston | last post by:
Some more, rather specific Access performance questions. IN a split front-end & back-end Access/Jet ONLY LAN situation, and with all query criteria fields and join fields indexed: 1. Is is...
6
by: androoo | last post by:
I have a source database which stores the main image. I read the image out as this : Dim strSQL As String Dim objData As clsDatabase Dim dr As OleDb.OleDbDataReader strSQL += "select * from...
4
by: Jim Devenish | last post by:
I have converted an Access back-end to SQL Server back-end but am having some problems. The Access to Access application has been running well for some years. I have successfully copied all the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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.