Creates, configures, reconfigures, and drops data caches, and provides information about them.
sp_cacheconfig [cachename [ ,"cache_size[P|K|M|G]" ] [,logonly | mixed ] [,strict | relaxed ] ] [, "cache_partition=[1|2|4|8|16|32|64]"]
is the name of the data cache to be created or configured. Cache names must be unique, and can be up to 30 characters long. A cache name does not have to be a valid Adaptive Server identifier, that is, it can contain spaces and other special characters.
is the size of the data cache to be created or, if the cache already exists, the new size of the data cache. The minimum size of a cache is 256 times the logical page size of the server. Size units can be specified with P for pages, K for kilobytes, M for megabytes, or G for gigabytes. The default is K. For megabytes and gigabytes, you can specify floating-point values. The cache size is in multiples of the logical page size.
specifies the type of cache.
specifies the cache replacement policy.
specifies the number of partitions to create in the cache.
Creates the data cache pub_cache with 10MB of space. All space is in the default logical page size memory pool:
sp_cacheconfig pub_cache, "10M"
Reports the current configuration of pub_cache and any memory pools in the cache:
sp_cacheconfig pub_cache
Drops pub_cache at the next start of Adaptive Server:
sp_cacheconfig pub_cache, "0"
Creates pub_log_cache and sets its type to logonly in a single step:
sp_cacheconfig pub_log_cache, "2000K", logonly
The first command creates the cache pub_log_cache with the default type mixed. The second command changes its status to logonly. The resulting configuration is the same as that in example 4:
sp_cacheconfig pub_log_cache, "2000K" sp_cacheconfig pub_log_cache, logonly
Creates a cache and sets the size, type, replacement policy and number of cache partitions:
sp_cacheconfig 'newcache', '50M', mixed, strict, "cache_partition=2"
The minimum cache size is 256 times the logical page size. For example, a 4K server would have a minimum cache size of 1024K.
If Adaptive Server is unable to allocate all the memory requested while you are creating a new cache or adding memory to an existing cache, it allocates all the available memory. However, this additional memory is allocated at the next reboot of Adaptive Server.
If there are objects bound to cache (including the default cache), you cannot delete the cache until you unbind the objects.
Some of the actions you perform with sp_cacheconfig are dynamic (do not require a reboot of Adaptive Server) and some are static (require a reboot). Table 1-7 describes which are dynamic and which are static:
When you first create a data cache:
All space is allocated to the logical page size memory pool.
The default type is mixed.
Figure 1-1 shows a data cache for a 2K server with two user-defined data caches configured and the following pools:
The default data cache must always have the type default, and no other cache can have the type default.
The Adaptive Server housekeeper task does not do any buffer washing in caches with a type of logonly or in caches with a relaxed LRU replacement policy.
The following commands perform only 2K I/O: disk init, some dbcc commands, and drop table. The dbcc checkdb and dbcc checktable commands can perform large I/O for tables, but perform 2K I/O on indexes. Table 1-8 shows cache usage, depending on the binding of the database or object.
Command |
Database bound |
Table or index is bound |
Database or object not bound |
---|---|---|---|
Bound cache |
N/A |
Default data cache |
|
N/A |
N/A |
Default data cache |
|
dbcc checkdb |
Bound cache |
N/A |
Default data cache |
dbcc checktable, indexalloc, tablealloc |
Bound cache |
Bound cache |
Default data cache |
Bound cache |
Bound cache |
Default data cache |
Recovery uses only the logical page size pool of the default data cache. All pages for all transactions that must be rolled back or rolled forward are read into and changed in this pool. Be sure that your default logical page size pool is large enough for these transactions.
When you use sp_cacheconfig with no parameters, it reports information about all of the caches on the server. If you specify only a cache name, it reports information about only the specified cache. If you use a fragment of a cache name, it reports information for all names matching “%fragment%”.
All reports include a block of information that reports information about caches, and a separate block of data for each cache that provides information about the pools within the cache.
The output below, from a server using 2K, shows the configuration for:
The default data cache with two pools: a 2K pool and a 16K pool. The default data cache has 2 partitions.
pubs_cache with two pools: 2K and 16K
pubs_log, with the type set to logonly and cache replacement policy set to relaxed, with a 2K pool and a 4K pool
Cache Name Status Type Config Value Run Value ----------------------- --------- -------- ------------ -------- default data cache Active Default 0.00 Mb 26.09 Mb pubs_cache Active Mixed 10.00 Mb 10.00 Mb pubs_log Active Log Only 2.40 Mb 2.40 M ------------- -------- Total 12.40 Mb 38.49 Mb =================================================================== Cache: default data cache, Status: Active, Type: Default Config Size: 0.00 Mb, Run Size: 26.09 Mb Config Replacement: strict LRU, Run Replacement: strict LRU Config Partition: 2, Run Partition: 2 IO Size Wash Size Config Size Run Size APF Percent -------- --------- ------------ ------------ ----------- 2 Kb 3704 Kb 0.00 Mb 18.09 Mb 10 16 Kb 1632 Kb 8.00 Mb 8.00 Mb 10 =================================================================== Cache: pubs_cache, Status: Active, Type: Mixed Config Size: 10.00 Mb, Run Size: 10.00 Mb Config Replacement: strict LRU, Run Replacement: strict LRU Config Partition: 1, Run Partition: 1 IO Size Wash Size Config Size Run Size APF Percent -------- --------- ------------ ------------ ----------- 2 Kb 1228 Kb 0.00 Mb 6.00 Mb 10 16 Kb 816 Kb 4.00 Mb 4.00 Mb 10 =================================================================== Cache: pubs_log, Status: Active, Type: Log Only Config Size: 2.40 Mb, Run Size: 2.40 Mb Config Replacement: relaxed LRU, Run Replacement: relaxed LRU Config Partition: 1, Run Partition: 1 IO Size Wash Size Config Size Run Size APF Percent -------- --------- ------------ ------------ ----------- 2 Kb 206 Kb 0.00 Mb 1.01 Mb 10 16 Kb 272 Kb 1.40 Mb 1.39 Mb 10
Table 1-9 lists the meaning of the columns in the output:
The status “Pend” is short for pending. It always occurs in combination with either “Act” for Active or “Del” for Delete. It indicates that a configuration action has taken place, but that the server must be restarted in order for the changes to take effect.
Figure 1-2: Effects of restarts and sp_cacheconfig on cache status
You can also configure caches and pools by editing the configuration file. For more information, see the System Administration Guide.
When Adaptive Server is first installed, all data cache memory is assigned to the logical page size pool of the cache named default data cache. The default data cache is used by all objects that are not explicitly bound to a data cache with sp_bindcache or whose databases are not bound to a cache.
When you create data caches, the memory allocation is validated against max memory. Memory for caches is allocated out of the memory allocated to Adaptive Server with the total logical_memory configuration parameter. To increase the amount of space available for caches, increase total logical memory, or decrease other configuration settings that use memory. If the sum of total logical memory and additional memory requested is greater than max memory, then Adaptive Server issues and error and does not perform the changes.
The default cache is used for all objects, including system tables, that are not bound to another cache, and is the only cache used during recovery. For more information, see the System Administration Guide.
A data cache requires a small percentage of overhead for structures that manage the cache. All cache overhead is taken from the default data cache. To see the amount of overhead required for a specific size of cache, use sp_helpcache, giving the size:
sp_helpcache "200M"
10.38Mb of overhead memory will be needed to manage a cache of size 200M
This is only an estimate of the overhead. The actual overhead may be larger because of runtime issues.
To change the size of an existing cache, specify the cache’s name and the new size.
If you increase the size of an existing cache, all of the added space is placed in the smallest pool.
To reduce the size of an existing cache, all of the space must be available in the logical page size pool. You may need to use sp_poolconfig to move space from other pools to this pool.
If you have a database or any nonlog objects bound to a cache, you cannot change its type to logonly.
Cache partitions can be used to reduce cache spinlock contention without needing to create separate caches and bind database objects to them. For more information on monitoring cache spinlock contention, see the Performance and Tuning Guide.
You can set the default number of cache partitions for all caches with the configuration parameter global cache partition number. See the System Administration Guide.
To drop or delete a data cache, change its size to 0, as shown in example 3. When you set a cache’s size to 0, the cache is marked for deletion. The cache remains active, and all objects that are bound to that cache continue to use it.
You cannot drop the default data cache.
If you delete a data cache, and there are objects bound to the cache, the cache is left as-is in memory and Adaptive Server issues the following message:
Cache (nmc3) not deleted dynamically. Objects are bound to the cache. Use sp_unbindcache_all to unbind all objects bound to the cache.
The entry corresponding to the cache in the configuration file is deleted, as well as the entries corresponding to the cache in sysconfigures, and the cache is deleted the next time Adaptive Server is restarted.
You cannot run sp_cacheconfig within a transaction.
Only a System Administrator can execute sp_cacheconfig to change cache configurations. Any user can execute sp_cacheconfig to view cache configurations.
Values in event and extrainfo columns from the sysaudits table are:
Event |
Audit option |
Command or access audited |
Information in extrainfo |
---|---|---|---|
38 |
exec_procedure |
Execution of a procedure |
|
System procedures sp_bindcache, sp_helpcache, sp_poolconfig, sp_unbindcache, sp_unbindcache_all
Copyright © 2005. Sybase Inc. All rights reserved. |