SET CACHED_PROCEDURES
The SET CACHED_PROCEDURES statement specifies the number of stored procedures that the database engine caches in memory for an SQL session.
Syntax
SET CACHED_PROCEDURES = number
Remarks
The value of number can be any whole number in the range zero through approximately two billion. The database engine automatically defaults to 50. Each session can change its number of cached procedures by issuing the SET statement.
The companion statement to SET CACHED_PROCEDURES is SET PROCEDURES_CACHE.
If you set both SET statements to zero, the database engine does not cache stored procedures. In addition, the engine removes any existing cache used for stored procedures. That is, the engine flushes from cache all stored procedures that were cached before you set both statements to zero.
If you set only one of the statements to a value, either zero or a nonzero value, the other statement is implicitly set to zero. The statement implicitly set to zero is ignored. For example, if you are only interested in caching 70 procedures and are not concerned with the amount of memory, set CACHED_PROCEDURES to 70. The database engine implicitly sets PROCEDURES_CACHE to zero, which ignores the setting.
The following condition applies if you set CACHED_PROCEDURES to a nonzero value. The database engine removes the least-recently-used procedures from the cache if the execution of a procedure causes the number of cached procedures to exceed the CACHED_PROCEDURES value.
If a memory cache is used, it retains a compiled version of a stored procedure after the procedure executes. Typically, caching results in improved performance for each subsequent call to a cached procedure. Note that excessive memory swapping, or thrashing, could occur depending on the cache settings and the SQL being executed by your application. Thrashing can cause a decrease in performance.
Registry Setting
In addition to the SET statement, the number of cached procedures can be specified with a registry setting. The registry settings apply to all sessions and provides a convenient way to set an initial value. Each session can override the registry setting for that particular session by using the SET statement.
The registry setting applies to all server platforms on which Pervasive PSQL Server is supported. You must manually modify the registry setting. On Windows, use the registry editor provided with the operating system. On Linux, you can use the psregedit utility.
If the registry setting is not specified, the database engine automatically defaults to 50.
1
HKEY_LOCAL_MACHINE\SOFTWARE\Pervasive Software\SQL Relational Engine
Note that in most Windows operating systems, the ‘Pervasive Software’ key is HKEY_LOCAL_MACHINE\SOFTWARE\PERVASIVE SOFTWARE. However, its location under HKEY_LOCAL_MACHINE\SOFTWARE can vary depending on the operating system.
2
3
Set CachedProcedures to the desired number of procedures that you want to cache.
1
PS_HKEY_CONFIG\SOFTWARE\Pervasive Software\SQL Relational Engine
2
3
Set CachedProcedures to the desired number of procedures that you want to cache.
Caching Exclusions
A stored procedure is not cached, regardless of the cache setting(s), for any of the following:
Examples
The following example sets a cache memory of 2 MB that stores up to 20 stored procedures.
SET CACHED_PROCEDURES = 20
SET PROCEDURES_CACHE = 2
============ 
The following example sets a cache memory of 1,000 MB that stores up to 500 stored procedures.
SET CACHED_PROCEDURES = 500
SET PROCEDURES_CACHE = 1000
============ 
The following example specifies that you do not want to cache stored procedures and that any existing procedures cache will be removed.
SET CACHED_PROCEDURES = 0
SET PROCEDURES_CACHE = 0
============ 
The following example specifies that you want to cache 120 stored procedures and ignore the amount of memory used for the cache.
SET CACHED_PROCEDURES = 120
(The database engine implicitly sets PROCEDURES_CACHE to zero.)
See Also
CREATE PROCEDURE
SET PROCEDURES_CACHE