473,379 Members | 1,170 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,379 software developers and data experts.

what do you prefer ?

Hey
I don't know what's best. I can invoke 20 times stored procedure with
diffrent id's to do something. Or put this id's as one long varchar string
and in stored procedure use some userDefined function to cut it into single
peaces. What's better way ? It seems like the second one ;)
Jarod

Jan 18 '06 #1
4 1093
jmi

Jarod wrote:
Hey
I don't know what's best. I can invoke 20 times stored procedure with
diffrent id's to do something. Or put this id's as one long varchar string
and in stored procedure use some userDefined function to cut it into single
peaces. What's better way ? It seems like the second one ;)
Jarod


If the stored proc you're invoking is on a server that's part of a
network you may want to go with the second option. Having too many
network-round-trips (especially on slow network) can make it seem that
your app is slow.

Jan 18 '06 #2
This is a bad idea, IMO. It makes the code more complex, and there are
ways around multiple network hops.

For example, the root for data adapters, DbDataAdapter, allows for batch
processing to occur. With this, you can have your SP invoked 20 times, but
have only one call made to the server.

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

"jmi" <mi**@askish.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...

Jarod wrote:
Hey
I don't know what's best. I can invoke 20 times stored procedure with
diffrent id's to do something. Or put this id's as one long varchar
string
and in stored procedure use some userDefined function to cut it into
single
peaces. What's better way ? It seems like the second one ;)
Jarod


If the stored proc you're invoking is on a server that's part of a
network you may want to go with the second option. Having too many
network-round-trips (especially on slow network) can make it seem that
your app is slow.

Jan 18 '06 #3
jmi
Jarod --
Does the proc return a result set? Not knowing what method you were
using to make the call...in general you want to reduce your round trips
when possible. But if your proc is using these IDs to fetch data then
I would agree with Nicholas...use DbDataAdapter or one of it's
descendents. Your proc can return the 20 resultsets from one call.

Jan 18 '06 #4
But presumably if your doing the same thing each time (give or take an id)
you could return 20 rows in a single result set.

Command batching is fine, but it is not necessarily supported on every
database server / version.

Personally, for this type of job I tend to go down the "single SP call
approach", where my SP accepts a varchar(8000) for the ids in a CSV format,
which I then pick apart using a table-udf (coded once, reused in many
places) - i.e. my udf splits the string and returns a single column,
multi-row result of values. I can then use this as the base for whatever
joins etc I need. This approach (after much peformance profiling) appears to
be better performing at the database - i.e. it can be (depending on
circumstances) much quicker to look in a table for 20 values (via an inner
join) than it can be to look for 1 value 20 times... plus any triggers etc
only get called once... plus less chance of getting a lock escalation issue
halfway through your method since you can take out an UPDLOCK on all the
data from the outset, rather than updating the first 15 only to find that
the 16th is locked, and then having to rollback the other 15...
Most of the above are SQL issues, not C# issues, but that's my opinion.

Marc
Jan 19 '06 #5

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

Similar topics

30
by: Reinhold Birkenfeld | last post by:
Hello, I know that there are different YAML engines for Python out there (Syck, PyYaml, more?). Which one do you use, and why? For those of you who don't know what YAML is: visit...
125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
11
by: modemer | last post by:
If I define the following codes: void f(const MyClass & in) {cout << "f(const)\n";} void f(MyClass in) {cout<<"f()\n";} MyClass myclass; f(myclass); Compiler complain that it can't find...
9
by: Jay | last post by:
Everywhere I go (read/browse) I see these parameters.... ByVal sender As Object, ByVal e As System.EventArgs Yet I never see them used within the function/method. Could someone tell me what they...
10
by: Just Me | last post by:
Does Me.Cursor.Current=Cursors.WaitCursor set the current property of Me.Cursor to Cursors.WaitCursor And Me.Cursor.Current=Cursors.Default set the Me.Current property to something (default)...
14
by: rohitpatel9999 | last post by:
Hi While developing any software, developer need to think about it's possible enhancement for international usage and considering UNICODE. I have read many nice articles/items in advanced C++...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
21
by: Tee | last post by:
Hi, Just curious what is clickone? Is it the same as Installshield? Been follow the following instructions and it seems to create an installation exe for me which is good but how come it...
30
by: Bill Reid | last post by:
#define MAX_VALUES 64 typedef struct { unsigned value_1; double value_2; double value_3; double value_4; } VALUES; typedef struct {
44
by: Steven D'Aprano | last post by:
I have a class which is not intended to be instantiated. Instead of using the class to creating an instance and then operate on it, I use the class directly, with classmethods. Essentially, the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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...

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.