473,729 Members | 2,328 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making stored procedures resident in memory

I am trying to determine the behaviour of stored procedures in DB2 V8.2.x in
Windows/Unix/Linux and how I can control that behaviour. Some documentation
in the manuals is confusing the issue somewhat.

First, am I right in understanding that the normal behaviour of a stored
procedure, fenced or unfenced, is to only go into memory when it is invoked
and to be swapped out of memory when it is not needed any more?

Second, am I right in understanding that setting KEEPFENCED = YES in the DBM
config parameters is the way to override the default behaviour and force the
stored procedure to stay resident even when it is not used?

Now, a word about the confusion in the manuals. I was researching this
question in the manuals and found a topic entitled "Specifying general
properties". It says that there is an option for 'Stay resident at exit' in
the Create Procedure notebook in the Development Center. The problem is that
I can't find any such option anywhere. I suspect that the manual is not in
sync with the code in the Development Center. I am experiencing this on a
V8.2.2 copy of DB2 at a client site.

Am I just particularly dense today or am I right that there is no such
setting for stored procedures? If I am being dense and I can set this value,
could someone tell me EXACTLY how to get to the panel that has this option?

If the manual is wrong, what's the best way to notify the technical writers
so that they can fix this?

Rhino

Nov 12 '05 #1
5 3394
"Rhino" <rh****@NOSPAM. sympatico.ca> wrote in message
news:47******** ************@ma gma.ca...
I am trying to determine the behaviour of stored procedures in DB2 V8.2.x in Windows/Unix/Linux and how I can control that behaviour. Some documentation in the manuals is confusing the issue somewhat.

First, am I right in understanding that the normal behaviour of a stored
procedure, fenced or unfenced, is to only go into memory when it is invoked and to be swapped out of memory when it is not needed any more?
Correct.
Second, am I right in understanding that setting KEEPFENCED = YES in the DBM config parameters is the way to override the default behaviour and force the stored procedure to stay resident even when it is not used?
Yes, but only for fenced stored procedures. When a fenced stored procedure
is executed, the DB2 agent intiating the CALL statement fires up a new
process (called db2fmp on UNIX/Linux or db2dari on Windows) that is used to
run the stored procedure. (By running the SP in this new process, the
engine is spared from undesireable effects should the SP do something
wacky.)

Unfenced stored procedures are always executed within the calling agent's
process space, and does not "stay resident" after it has finished executing.
(See more below.)
Now, a word about the confusion in the manuals. I was researching this
question in the manuals and found a topic entitled "Specifying general
properties". It says that there is an option for 'Stay resident at exit' in the Create Procedure notebook in the Development Center. The problem is that I can't find any such option anywhere. I suspect that the manual is not in
sync with the code in the Development Center. I am experiencing this on a
V8.2.2 copy of DB2 at a client site.
From the online documents I read, this option is only valid for DB2 on
zSeries.
From the DB2 UDB Information Center:

Administering
- Mainframe and midrange servers
-- Administering DB2 UDB for z/OS and OS/390 subsystems [ first hint! ]
--- Administering DB2 objects
---- Applications Objects
----- Procedures
------- Specifying general properties
Am I just particularly dense today or am I right that there is no such
setting for stored procedures? If I am being dense and I can set this value, could someone tell me EXACTLY how to get to the panel that has this option?

I believe there is no setting in the Development Center to do this.
However, there is a way to do it using C code in a C-language stored
procedure. This procedure was doucmented in v7 but I can't find it in the
v8 docs, so it's likely unsupported.

Within a C-language stored procedure, the return code of your procedure can
indicate to DB2 whether the procedure should stay resident or whether it
should be unloaded.

// start of SP
SQL_API_RC stored_procedur e(...)
{
sqlint32 rc;

// SP logic

if (sqlca.sqlcode >= 0) {
rc = SQLZ_HOLD_PROC;
} else {
rc = SQLZ_DISCONNECT _PROC;
}

return rc;
}
// end of SP
If the manual is wrong, what's the best way to notify the technical writers so that they can fix this?


Open a PMR. But not in this case.

--
Matt Emmerton
Nov 12 '05 #2
Rhino wrote:
I am trying to determine the behaviour of stored procedures in DB2 V8.2.x in
Windows/Unix/Linux and how I can control that behaviour. I assume SQL Procedures (Matt answered for external routines). SQL
Procedures in DB2 V8.2 do not use DLL anymore. SQL Procedures use p-code
which is run by the PVM (virtual machine)
First, am I right in understanding that the normal behaviour of a stored
procedure, fenced or unfenced, is to only go into memory when it is invoked
and to be swapped out of memory when it is not needed any more? An SQL Procedures (and teh packages of external routines) compete with
other packages and dynamic SQL for the PACKAGE HEAP. It is pinned only
while executing. When dealing with lots/big stored procedures the
package heap should be sized generously. It can make up to a magnitude
difference in performance.
Second, am I right in understanding that setting KEEPFENCED = YES in the DBM
config parameters is the way to override the default behaviour and force the
stored procedure to stay resident even when it is not used?

The executible of an external and fenced routine, unless the OS decides
to swap it out. It competes with any other library.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Nov 12 '05 #3
For fenced stored procedures (KEEPFENCED=YES ) we have a library
management model that keeps all recently used libraries loaded in
memory, but dynamically determines when to unload infrequently used
libraries.

We have an LRU of the 5 most recently used libraries...the se libraries
will stay loaded even if no stored procedure has been run in the db2fmp
for days.

To prevent the amount of os space consumed from growing uncontrollably,
we may unload any other library that has not been accessed for a
particular interval of time.

The 'stay loaded' feature you reference below about was actually only
ever an 'immediate load/unload' feature, implemented as the return code
from the stored procedure. It was only ever looked at for the now
defunct db2dari style stored procedures...ev en with this return code
handling, in v7 we only had the LRU functionality for library
management...be cause of this, even if you told db2 to keep your library
loaded, it would only stay loaded until it was no longer one of the 5
most recently invoked libraries.

Trusted stored procedures are always unloaded on the application or UOW
boundary, depending on whether you're running concentrator enabled or not.

Rhino wrote:
I am trying to determine the behaviour of stored procedures in DB2 V8.2.x in
Windows/Unix/Linux and how I can control that behaviour. Some documentation
in the manuals is confusing the issue somewhat.

First, am I right in understanding that the normal behaviour of a stored
procedure, fenced or unfenced, is to only go into memory when it is invoked
and to be swapped out of memory when it is not needed any more?

Second, am I right in understanding that setting KEEPFENCED = YES in the DBM
config parameters is the way to override the default behaviour and force the
stored procedure to stay resident even when it is not used?

Now, a word about the confusion in the manuals. I was researching this
question in the manuals and found a topic entitled "Specifying general
properties". It says that there is an option for 'Stay resident at exit' in
the Create Procedure notebook in the Development Center. The problem is that
I can't find any such option anywhere. I suspect that the manual is not in
sync with the code in the Development Center. I am experiencing this on a
V8.2.2 copy of DB2 at a client site.

Am I just particularly dense today or am I right that there is no such
setting for stored procedures? If I am being dense and I can set this value,
could someone tell me EXACTLY how to get to the panel that has this option?

If the manual is wrong, what's the best way to notify the technical writers
so that they can fix this?

Rhino

Nov 12 '05 #4
"Sean McKeough" <mc******@nospa m.ibm.com> wrote in message
news:42******** @news3.prserv.n et...
For fenced stored procedures (KEEPFENCED=YES ) we have a library management
model that keeps all recently used libraries loaded in memory, but
dynamically determines when to unload infrequently used libraries.

We have an LRU of the 5 most recently used libraries...the se libraries
will stay loaded even if no stored procedure has been run in the db2fmp
for days.

To prevent the amount of os space consumed from growing uncontrollably, we
may unload any other library that has not been accessed for a particular
interval of time.

The 'stay loaded' feature you reference below about was actually only ever
an 'immediate load/unload' feature, implemented as the return code from
the stored procedure. It was only ever looked at for the now defunct
db2dari style stored procedures...ev en with this return code handling, in
v7 we only had the LRU functionality for library management...be cause of
this, even if you told db2 to keep your library loaded, it would only stay
loaded until it was no longer one of the 5 most recently invoked
libraries.

Trusted stored procedures are always unloaded on the application or UOW
boundary, depending on whether you're running concentrator enabled or not.

Are you saying that SQL Stored Procedures are not in the package cache?
Nov 12 '05 #5

"Mark A" <no****@nowhere .com> wrote in message
news:cf******** ************@co mcast.com...
"Sean McKeough" <mc******@nospa m.ibm.com> wrote in message
news:42******** @news3.prserv.n et...
For fenced stored procedures (KEEPFENCED=YES ) we have a library management model that keeps all recently used libraries loaded in memory, but
dynamically determines when to unload infrequently used libraries.

We have an LRU of the 5 most recently used libraries...the se libraries
will stay loaded even if no stored procedure has been run in the db2fmp
for days.

To prevent the amount of os space consumed from growing uncontrollably, we may unload any other library that has not been accessed for a particular
interval of time.

The 'stay loaded' feature you reference below about was actually only ever an 'immediate load/unload' feature, implemented as the return code from
the stored procedure. It was only ever looked at for the now defunct
db2dari style stored procedures...ev en with this return code handling, in v7 we only had the LRU functionality for library management...be cause of
this, even if you told db2 to keep your library loaded, it would only stay loaded until it was no longer one of the 5 most recently invoked
libraries.

Trusted stored procedures are always unloaded on the application or UOW
boundary, depending on whether you're running concentrator enabled or not.

Are you saying that SQL Stored Procedures are not in the package cache?


SQL stored procs are in the package cache. What Sean is talking about are
non-SQL stored procs, which have a backing shared object which needs to be
loaded/unloaded by the OS, and DB2 only keeps the 5 most recently used
object loaded at one time.

--
Matt Emmerton
Nov 12 '05 #6

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

Similar topics

4
23748
by: Shinpei Kuga | last post by:
I have MS SQL Server 7 and over the years have built quite a few Stored Procedures. It would be extremely convenient if I could print out or view ALL the text of ALL the stored proceudres at once. Is there a way i can do this? Is tehre a way I can make a quick print out?
4
1404
by: HeadScratcher | last post by:
We have written an application which splits up our customers data into their individual databases. The structure of the databases is the same. Is it better to create the same stored procedures in each database or have them in one central location and use the sp_executesql and execute the generated the SQL statement. Thank you. Mayur Patel
5
4532
by: Jeff | last post by:
I have question about differences in fenced sql procedures and fenced stored procedures. Do fenced sql procedures take up an extra memory segment when executed? Reason I ask is we have several fenced sql procedures that have been excuting o.k. We implemented a fenced stored procedure on a C program and when trying to execute it, we get the "DIA3833C The system memory limit was reached."
5
3483
by: Tim Marshall | last post by:
I was following the thread "Re: Access Treeview - Is it Safe Yet?" with interest and on reading the post describing Lauren Quantrell's SmartTree, I've run into something I don't understand: Stored Procedures. I thought stored pricedures were an Oracle/MS SQL Server thing and don't know how they work with Access Jet. I've looked at some of the help on stored procedures in A2003, but really don't understand what's going on. Can someone...
8
1310
by: Steven Blair | last post by:
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...
45
3406
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
4
3995
by: nishi57 | last post by:
I hope I can get some help regarding this issue, which has been going on for a while. I have a desktop user who is having problem running "Stored Procedures". The DB2 Connect application works fine but when he runs the stored procedure, he gets the following error message. "SYSPROC".CSGCSB54 - Run started. Data returned in result sets is limited to the first 100 rows. Data returned in result set columns is limited to the first 20...
0
1411
by: vanesa | last post by:
Hi, In a client we must begin to program many stored procedures of DB2. The following doubts arise to me that I raise you to see if you can help me: 1. From a point of view of the programming: I need some document or manual (preferably in Spanish) that explains rules on like programming a procedure stored so that their yield is optimal, like structuring it (for example, if he is better to do several procedures stored small or is better to...
1
1622
by: DR | last post by:
what are the memory caps for threads running as a CLR stored procedure executed by sql server 2005? is it limited by OS only or also by sql servers memory limits? e.g. lets say my clr stored procedure is executed by sql server 2005 then it creates 10 threads and each thread builds a giant array on the stack, is the limits of each array limited by sql server or the os? do these clr stored procedures run inside the sql server address space or...
0
9284
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9148
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8151
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4528
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.