473,399 Members | 3,302 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.

Re using Stored Procedures

Hi,

I have a system which processes 1000's of transactions per hour. Part of
each transaction process invloves me calling a stored procdure which
updates various tables.
What I want to know is, is a Stored Procedure like a function in terms
of performance, each time the SP is about to get called, the function
will have memory allocated for it on the stack(including all variables
required). So, this process would happen however many transactions I was
processing.

If this is the case, is there a way in c# to cache the stored procedure
to prevent this happening. After the first transaction has been
processed, the SP will exist in memory.

I am using SQL Server.

Any help on this would be appreciated.

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
8 1296

"Steven Blair" <st**********@btinternet.com> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a system which processes 1000's of transactions per hour. Part of
each transaction process invloves me calling a stored procdure which
updates various tables.
What I want to know is, is a Stored Procedure like a function in terms
of performance, each time the SP is about to get called, the function
will have memory allocated for it on the stack(including all variables
required). So, this process would happen however many transactions I was
processing.

If this is the case, is there a way in c# to cache the stored procedure
to prevent this happening. After the first transaction has been
processed, the SP will exist in memory.

I am using SQL Server.


The SP will be cached in memory by Sql Server automatically. Sql Server may
allocate storage for the parameters and local variables, but that is so
cheap it isn't even worth considering.

David
Nov 16 '05 #2
Hi Steven:

When SQL Server encounters a stored procedure it needs to generate an
optimized plan of execution to run the stored procedure. This plan is
cached by SQL Server and may be reused on a subsequent calls.

There is realy nothing you can do from c# to further optimize this
process, but you could monitor SQL Server to measure how many
recompiles take place with perfmon.

Sometimes a saved query plan will get kicked out of the cache because
it is not used frequently, for instance. Other times SQL might force
a recompile because the underlying data has changed and it might be
able to generate a better plan. Sometimes the SQL you write can impact
the cacheability of the plan. Procedures that intermingle DDL and DML
(to create temp tables for instance) can create procedures that need
to recompile.

--
Scott
http://www.OdeToCode.com
On Wed, 25 Aug 2004 05:42:18 -0700, Steven Blair
<st**********@btinternet.com> wrote:
Hi,

I have a system which processes 1000's of transactions per hour. Part of
each transaction process invloves me calling a stored procdure which
updates various tables.
What I want to know is, is a Stored Procedure like a function in terms
of performance, each time the SP is about to get called, the function
will have memory allocated for it on the stack(including all variables
required). So, this process would happen however many transactions I was
processing.

If this is the case, is there a way in c# to cache the stored procedure
to prevent this happening. After the first transaction has been
processed, the SP will exist in memory.

I am using SQL Server.

Any help on this would be appreciated.

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #3
Steven,

In addition to what David and Scott said, your transaction rate is
actually pretty low (even at 9999 an hour, that's a little under 3 a second,
which, depending on the stored procedure, really is nothing for SQL server
to handle). It is good that you have stored procedures, but with this low
of a throughput, I would say that you can't do better than stored
procedures.

However, this would make one wonder why you ask the question. Are you
experiencing a bottleneck, and if so, what are you doing that could be
causing it.

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

"Steven Blair" <st**********@btinternet.com> wrote in message
news:Oi**************@TK2MSFTNGP10.phx.gbl...
Hi,

I have a system which processes 1000's of transactions per hour. Part of
each transaction process invloves me calling a stored procdure which
updates various tables.
What I want to know is, is a Stored Procedure like a function in terms
of performance, each time the SP is about to get called, the function
will have memory allocated for it on the stack(including all variables
required). So, this process would happen however many transactions I was
processing.

If this is the case, is there a way in c# to cache the stored procedure
to prevent this happening. After the first transaction has been
processed, the SP will exist in memory.

I am using SQL Server.

Any help on this would be appreciated.

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #4
We are looking at ways yo put through more transactions.
Studying the syste, the time it takes to load the transactions is the
killer. The numbers I told you (10000 per hour) is actually a lot less
than we are trying. I think we should be doing 4/5 second anyway.
Its quite a lot of hits to the Database. What I might have missed is the
amount of work the SP's actually do. This isnt just a few lines, we are
talking pages of code.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #5

"Steven Blair" <st**********@btinternet.com> wrote in message
news:ee**************@TK2MSFTNGP11.phx.gbl...
We are looking at ways yo put through more transactions.
Studying the syste, the time it takes to load the transactions is the
killer. The numbers I told you (10000 per hour) is actually a lot less
than we are trying. I think we should be doing 4/5 second anyway.
Its quite a lot of hits to the Database. What I might have missed is the
amount of work the SP's actually do. This isnt just a few lines, we are
talking pages of code.


If you are invoking the SP many times in quick succession, you should wrap
multiple calls in one transaction. SQL must do a certian amount of physical
IO to commit each transaction. If you don't wrap your commands in a
transaction, then SQL must commit after each statement which updates data.
There may be many such statements in each procedure call, so this can be a
significant bottleneck.

David
Nov 16 '05 #6
David,

Not sure I understand what you mean.
One transaction requires a lot of processing before being loaded. One SP
is is responsible for this. In this SP are multiple statments, insert,
updated multiple tables.

As Is aid before, the SP' can be pages long.

Steven
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #7
Hi Steven:

There is a lot of good information in the following document:

Improving .NET Application Performance and Scalability
http://msdn.microsoft.com/library/de...l/scalenet.asp

Particularly:

Chapter 12 - Improving ADO.NET Performance
http://msdn.microsoft.com/library/de...netchapt12.asp

Chapter 14 - Improving SQL Server Performance
http://msdn.microsoft.com/library/de...netchapt14.asp

--
Scott
http://www.OdeToCode.com

On Wed, 25 Aug 2004 10:52:19 -0700, Steven Blair
<st**********@btinternet.com> wrote:
We are looking at ways yo put through more transactions.
Studying the syste, the time it takes to load the transactions is the
killer. The numbers I told you (10000 per hour) is actually a lot less
than we are trying. I think we should be doing 4/5 second anyway.
Its quite a lot of hits to the Database. What I might have missed is the
amount of work the SP's actually do. This isnt just a few lines, we are
talking pages of code.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


Nov 16 '05 #8

"Steven Blair" <st**********@btinternet.com> wrote in message
news:uz***************@tk2msftngp13.phx.gbl...
David,

Not sure I understand what you mean.
One transaction requires a lot of processing before being loaded. One SP
is is responsible for this. In this SP are multiple statments, insert,
updated multiple tables.

As Is aid before, the SP' can be pages long.


Your procedures may run significantly faster if you start a SqlTransaction.
If you don't start a transaction then after each seperate insert, update or
delete, Sql Server must flush the transaction log to disk. If you start a
transaction, Sql Server can wait until you commit the transaction to flush
the log to disk.

David
Nov 16 '05 #9

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

Similar topics

10
by: Dragonhunter | last post by:
Hello, The aspfaq.com seems to really push stored procedures, and I hear the same advice here all the time. So I want to take the advice. Is it possible to create and practically maintain,...
2
by: Yves Touze | last post by:
Hi All, I'm trying to migrate from SQL Server 7.0 to SQL Server 2000. I've got some ASP page which call VB components that retrieve shaped recordsets from SQL Server using the MSDATASHAPE...
18
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the...
5
by: gilles27 | last post by:
I've ready many of the posts on this and other newsgroups in which people describe working practices for source control of database scripts. We are looking to implement something similar in my...
2
by: scott | last post by:
Hi, Just wondering what sort of problems and advantages people have found using stored procedures. I have an app developed in VB6 & VB.NET and our developers are starting to re-write some of the...
10
by: serge | last post by:
Using "SELECT * " is a bad practice even when using a VIEW instead of a table? I have some stored procedures that are identical with the difference of one statement in the WHERE clause. If I...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
0
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how...
45
by: John | last post by:
Hi When developing vb.bet winform apps bound to sql server datasource, is it preferable to use SELECTs or stored procedure to read and write data from/to SQL Server? Why? Thanks Regards
2
by: pascal.baetscher | last post by:
Hello everyone, I face currently a problem where I could need some input for searching the source of the Problem System: SQL Server 9.0 I fill from Database A with triggers Database B,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.