472,352 Members | 1,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,352 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 3257
"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...
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...
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...
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,...
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...
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...
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...
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...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

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.