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

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 3368
"Rhino" <rh****@NOSPAM.sympatico.ca> wrote in message
news:47********************@magma.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_procedure(...)
{
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...these 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...even with this return code
handling, in v7 we only had the LRU functionality for library
management...because 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******@nospam.ibm.com> wrote in message
news:42********@news3.prserv.net...
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...these 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...even with this return code handling, in
v7 we only had the LRU functionality for library management...because 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********************@comcast.com...
"Sean McKeough" <mc******@nospam.ibm.com> wrote in message
news:42********@news3.prserv.net...
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...these 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...even with this return code handling, in v7 we only had the LRU functionality for library management...because 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
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....
4
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...
5
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...
5
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...
8
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,...
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
4
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...
0
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:...
1
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...
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: 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
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
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?
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
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
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...

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.