Tuning the DB2 Subsystem

 <  Day Day Up  >  

The first level of DB2 tuning to be discussed in this chapter is at the DB2 subsystem level. This type of tuning is generally performed by a DB2 systems programmer or database administrator. Several techniques can be used to tune DB2 itself. These techniques can be broken down into three basic categories:

  • DB2 Catalog tuning techniques

  • Tuning DB2 system parameters

  • Tuning the IRLM

Each of these tuning methods is covered in the following sections.

Tuning the DB2 Catalog

One of the major factors influencing overall DB2 subsystem performance is the physical condition of the DB2 Catalog and DB2 Directory tablespaces. These tablespaces are not like regular DB2 tablespaces.

TUNING STRATEGY

Ensure that the DB2 Catalog data sets are not in multiple extents. When a data set spans more than one extent, overhead accrues due to the additional I/O needed to move from extent to extent. To increase the size of DB2 Catalog data sets, you must invoke a DB2 Catalog recovery. This procedure is documented in Chapter 6 of the IBM DB2 Administration Guide .


TUNING STRATEGY

Institute procedures to analyze the organization of the DB2 Catalog and DB2 Directory tablespaces and indexes. You can use DB2 utilities to reorganize inefficient objects in the DB2 Catalog and DB2 Directory. In-depth information on reorganizing the DB2 Catalog is provided in Appendix H.


TUNING STRATEGY

It also is possible to issue the REBUILD INDEX utility on the DB2 Catalog indexes, which reads the table to rebuild the index, and thereby reorganizes the index, too. You can choose to rebuild the DB2 Catalog indexes when DB2 use grows.


DB2 does not make use of indexes when it accesses the DB2 Catalog for internal use. For example, binding, DDL execution, and authorization checking do not use DB2 indexes. Instead, DB2 traverses pointers, or links, maintained in the DB2 Catalog. These pointers make internal access to the DB2 Catalog very efficient.

The DB2 Catalog indexes are used only by users issuing queries against DB2 Catalog tables. Whether these indexes are used or not is based on the optimization of the DB2 Catalog queries and whether the DB2 optimizer deems that they are beneficial.

TUNING STRATEGY

Execute RUNSTATS on the DB2 Catalog tablespaces and indexes. Without current statistics, DB2 cannot optimize DB2 Catalog queries. Additionally, RUNSTATS provides statistics enabling DBAs to determine when to reorganize the DB2 Catalog tablespaces.


Although it is difficult to directly influence the efficiency of internal access to the DB2 Catalog and DB2 Directory, certain measures can be taken to eliminate obstructions to performance. For instance, follow proper data set placement procedures to reduce DASD head contention .

TUNING STRATEGY

Do not place other data sets on the volumes occupied by the DB2 Catalog and DB2 Directory data sets. Place the DB2 Catalog data sets on different volumes than the DB2 Directory data sets. Place DB2 Catalog tablespaces on different volumes than the indexes on the DB2 Catalog.


TUNING STRATEGY

If you have additional DASD, consider separating the DB2 Catalog tablespaces by function, on distinct volumes.

On volume #1, place SYSPLAN , which is the tablespace used by application programs for binding plans.

On volume #2, place SYSPKAGE , which is the tablespace used by application programs for binding packages. Keep these tablespaces on separate volumes. Because plans can be composed of multiple packages, DB2 may read from SYSPKAGE and write to SYSPLAN when binding plans. Failure to separate these two tablespaces can result in head contention.

On volume #3, place SYSCOPY , which is the tablespace used by utilities. This enhances the performance of DB2 utilities.

On volume #4, place the remaining DB2 Catalog tablespaces. These tablespaces can coexist safely on a single volume because they are rarely accessed in a way that causes head contention. You might choose to separate system-related tablespaces from application- related tablespaces. For example, SYSSEQ , SYSSEQ2 , SYSJAVA , SYSJAUXA , SYSJAUXB , and SYSGRTNS are more application-focused and could be placed on a separate device from the other, more system-focused DB2 Catalog tablespaces.


The DB2 Catalog is central to most facets of DB2 processing. It records the existence of every object used by DB2. As such, it is often queried by DBAs, programmers, and ad hoc users. Large queries against the DB2 Catalog can cause performance degradation.

TUNING STRATEGY

Consider isolating the DB2 Catalog tablespaces and indexes in a single buffer pool. This buffer pool must be BP0 because DB2 forces the catalog objects to be created in BP0 . To isolate the system catalog objects in BP0 , ensure that all other objects are created in other buffer pools ( BP1 through BP49 , BP8K0 through BP8K9 , BP16K0 through BP16K9 , BP32K , and BP32K1 through BP32K9 ).


TUNING STRATEGY

Consider monitoring the SQL access to DB2 Catalog tables and creating additional indexes on tables that are heavily accessed by non-indexed columns .


Additionally, many DB2 add-on tools access the DB2 Catalog as they execute, which can result in a bottleneck. Because the DB2 Catalog provides a centralized repository of information on all objects defined to DB2, it is natural for programmers, analysts, and managers to request access to the DB2 Catalog tables for queries. This can cause contention and reduce performance.

TUNING STRATEGY

Consider making a shadow copy of the DB2 Catalog for programmer queries and use by vendor tools. This reduces DB2 Catalog contention. If most external access to the DB2 Catalog is redirected to a shadow copy, internal access is much quicker. The shadow DB2 Catalog tables should never be allowed to get too outdated . Consider updating them weekly.

To implement this strategy, you must plan a period of inactivity during which the DB2 Catalog can be successfully copied to the shadow tables. Consider using ISOLATION(UR) when unloading the DB2 Catalog rows for movement to the shadow copy. For assistance with implementing this strategy, follow the guidelines presented in Chapter 5, "Data Definition Guidelines," for denormalizing with shadow tables.


TUNING STRATEGY

If you don't use a shadow copy of the DB2 Catalog, consider limiting access to the production DB2 Catalog by allowing queries only through views. You can create views so that users or applications can see only their own data. Additionally, views joining several DB2 Catalog tables can be created to ensure that DB2 Catalog tables are joined in the most efficient manner.


Finally, remember that when DB2 objects are created, DB2 must read and update several DB2 Catalog tables. This results in many locks on DB2 Catalog pages as the objects are being built. To reduce contention and the resultant timeouts and deadlocks, schedule all DDL during off-peak processing periods (for example, in the early morning after the batch cycle but before the first online use, or over the weekend ).

TUNING STRATEGY

Consider priming the DB2 Catalog with objects for each new authorization ID that will be used as a creator. This avoids what some people refer to as the "first-time effect." Whenever initial inserts are performed for an authorization ID, additional overhead is involved in updating indexes and pointers. So, for each new authorization ID, consider creating a dummy database, tablespace, table, index, synonym, view, package, and plan. As is the case with all DDL, you should do this only at an off-peak time. These objects need never be used and can be dropped or freed after actual DB2 objects have been created for the authorization ID. This is less of a concern for a test DB2 subsystem where performance is a less critical issue.


TUNING STRATEGY

Keep the DB2 Catalog and Directory as small as possible. Do not use the DB2 Catalog to retain historical objects, plans, packages, or recovery information. If any of this information might be beneficial, use a historical copy or version of the DB2 Catalog to retain this information. For example,

  • Delete the sample tables that do not apply to the current (and perhaps previous) version of DB2.

  • Be sure to delete the SYSDDF.SYSDDF data sets and objects. These were used by the communications database that was merged with the DB2 Catalog in Version 5.

  • Always delete plans and packages that are not used. For instance, V7 users should delete DSNTEP2 plans that invoke V6 or earlier programs.

  • Delete SYSCOPY rows that are not useful. This is done using the MODIFY RECOVERY utility.


DSNZPARMs

The makeup of the DB2 environment is driven by a series of system parameters specified when DB2 is started. These system parameters are commonly referred to as DSNZPARMs, or ZPARMs for short. The DSNZPARMs define the settings for many performance-related items. Several of the ZPARMs influence overall system performance.

graphics/v7_icon.gif

Most of the DSNZPARMs can be modified dynamically using the SET SYSPARM command.


NOTE

Prior to DB2 V3, buffer pool specifications were coded into the ZPARMs. For DB2 V3 and subsequent versions they are set using the ALTER BUFFERPOOL command.


A complete listing of DSNZPARM parameters can be found Appendix C of the IBM DB2 Installation Guide .

Traces

Traces can be started automatically based on DSNZPARM specifications. Most shops use this feature to ensure that certain DB2 trace information is always available to track performance problems. The DSNZPARM options for automatically starting traces are AUDITST , TRACSTR , SMFACCT , SMFSTAT , and MON .

TUNING STRATEGY

Ensure that every trace that is automatically started is necessary. Recall from Chapter 24, "Traditional DB2 Performance Monitoring," that traces add overhead. Stopping traces reduces overhead, thereby increasing performance.


DB2 traces can be started by IFCID. The acronym IFCID stands for Instrumentation Facility Component Identifier. An IFCID basically names a single traceable event in DB2. By specifying IFCIDs when starting a trace, you can limit the amount of information collected to just those events you need to trace.

Locking

Lock escalation thresholds are set by the following DSNZPARM options of the system parameters:

NUMLKTS

Maximum number of page or row locks for a single tablespace before escalating them to a tablespace lock

NUMLKUS

Maximum number of page or row locks held by a single user on all table spaces before escalating all of that user 's locks to a tablespace lock


TUNING STRATEGY

To increase concurrency, set the NUMLKTS and NUMLKUS thresholds high to minimize lock escalation. For some environments, the default values are adequate ( NUMLKTS=1000 and NUMLKUS=10000 ). However, for a high-volume environment these numbers may need to be adjusted upward to avoid contention problems.


Lock escalation can also be controlled on a tablespace-by-tablespace basis using the LOCKMAX parameter. Information on the LOCKMAX parameter can be found in Chapter 5. When specified, the LOCKMAX parameter overrides NUMLKTS .

Logging

The parameters that define DB2's logging features are also specified in the DSNZPARMs. Options can be used to affect the frequency of writing log buffers and the size of the log buffers. The DSNZPARM options that affect DB2 logging are CHKFREQ , INBUFF , and LOGAPSTG .

TUNING STRATEGY

The CHKFREQ parameter indicates how often DB2 takes system checkpoints and it can be specified as either the number of log records written or as a time duration. Restart time is directly affected by how many log records are written after the latest system checkpoint. The more log records, the longer the restart time.

If the value of CHKFREQ is within the range of 200 to 16000000 , it indicates the number of log records written before a checkpoint is taken. If CHKFREQ is within the range of 1 to 60, it indicates the number of minutes between checkpoints.

Additionally, DB2 takes a checkpoint when an active log is switched. The active log is switched when it becomes full or the ARCHIVE LOG command is issued.

You can use the SET LOG command or the SET SYSPARM command to change the CHKFREQ parameter dynamically. If you use SET LOG , the value is changed, but only for as long as the DB2 subsystem remains operational. When DB2 shuts down and is restarted, CHKFREQ will reset back to its previous value. If you use SET SYSPARM to change CHKFREQ , the value is changed now and forevermore ”even if DB2 is recycled.


DB2 fills log buffers and eventually the log records are written to an active log data set. The write occurs when the buffers fill up, when the write threshold is reached or when the DB2 subsystem forces the log buffer to be written.

TUNING STRATEGY

Many shops simply use the default log output buffer size of 4000K. This is adequate for small shops (those with only one or two small, non-critical DB2 applications). The maximum value for OUTBUFF is 400MB. Shops with large, critical DB2 applications should probably specify a very large OUTBUFF ”up to the maximum of 400MB if sufficient memory is available.

By increasing the OUTBUFF size, DB2 can perform better because more logging activity is performed in memory. Log writes can improve because DB2 is less likely to need to wait for a buffer. Log reads can improve because, if the information is in the log buffer, DB2 does not need to read the information from disk storage.

Be aware that when the log buffer is full the entire DB2 subsystem will stop until writes have completed and log buffers are available again.


The LOGAPSTG parameter represents the maximum DBM1 storage that can be used by the fast log-apply process. The default value is 0MB, which means that the fast log-apply process is disabled except during DB2 restart. During DB2 restart, the fast log-apply process is always enabled.

TUNING STRATEGY

Plan for 10MB of storage for each concurrent RECOVER job that you want to have faster log apply processing. So, if you plan on having 3 concurrent RECOVER jobs, specify 30MB for LOGAPSTG .


Timeouts

The amount of time to wait for an unavailable resource to become available before timing out is controlled by the DSNZPARM value, IRLMRWT . When one user has a lock on a DB2 resource that another user needs, DB2 waits for the time specified by IRLMRWT and then issues a -911 or -913 SQLCODE .

TUNING STRATEGY

IRLMRWT controls the amount of time to wait before timing out both foreground and background tasks . Therefore, you must balance a reasonable amount of time for a batch job to wait versus a reasonable amount of time for an online transaction to wait. If this value is too high, transactions wait too long for unavailable resources before timing out. If this value is too low, batch jobs abend with timeouts more frequently. The default value of 60 seconds is usually a reasonable setting.


TUNING STRATEGY

Sometimes it is impossible to find a compromise value for IRLMRWT . Online transactions wait too long to time out, or batch jobs time out too frequently. If this is the case, consider starting DB2 in the morning for online activity with a modest IRLMRWT value (45 or 60 seconds) and starting it again in the evening for batch jobs with a larger IRLMRWT value (90 to 120 seconds). In this scenario, DB2 must go down and come back up during the day. (This might be impossible for shops running 24 hours a day, 7 days a week.)


Additionally, the UTIMOUT parameter can be used to indicate the number of resource timeout cycles that a utility will wait for a drain lock before timing out.

TUNING STRATEGY

The value of UTIMOUT is based on the value of IRLMRWT . If UTIMOUT is set to 6 (which is the default), a utility will wait six times as long as an SQL statement before timing out.


Active Users

The number of active users can be controlled by the DSNZPARM settings, including the following:

CTHREAD

Controls the absolute number of maximum DB2 threads that can be running concurrently

IDFORE

Sets the maximum number of TSO users that can be connected to DB2 simultaneously

IDBACK

Controls the number of background batch jobs accessing DB2

MAXDBAT

Specifies the maximum number of concurrent distributed threads that can be active at one time


TUNING STRATEGY

Use the CTHREAD parameter to ensure that no more than the planned maximum number of DB2 users can access DB2 at a single time. Failure to keep this number synchronized with other DB2 resources can cause performance degradation. For example, if your buffer pools and EDM pool are tuned to be optimal for 30 users, do not allow CTHREAD to exceed 30 until you have reexamined these other areas.

The same guideline applies for IDFORE to control TSO use, IDBACK to control the proliferation of batch DB2 jobs, and MAXDBAT to control distributed DB2 jobs.


EDM Pool

The size of the EDM pool is specified in the DSNZPARM value named EDMPOOL . The use of the EDM pool and its requirements are described in Chapter 27, "Tuning DB2's Environment," in the section titled "Tuning Memory Use."

Drowning in a Buffer Pool of Tears

The single most critical system-related factor influencing DB2 performance is the setup of sufficient buffer pools. A buffer pool acts as a cache between DB2 and the physical disk storage devices on which the data resides. After data has been read, the DB2 Buffer Manager places the page into a buffer pool page stored in memory. Buffer pools, therefore, reduce the impact of I/O on the system by enabling DB2 to read and write data to memory locations synchronously, while performing time- intensive physical I/O asynchronously.

Through judicious management of the buffer pools, DB2 can keep the most recently used pages of data in memory so that they can be reused without incurring additional I/O. A page of data can remain in the buffer pool for quite some time, as long as it is being accessed frequently. Figure 28.1 shows pages of data being read into the buffer pool and reused by multiple programs before finally being written back to disk. Processing is more efficient as physical I/Os decrease and buffer pool I/Os increase.

Figure 28.1. DB2 buffer pool processing.

graphics/28fig01.gif


How does the buffer pool work? DB2 performs all I/O-related operations under the control of its Buffer Manager component. As pages are read, they are placed into pages in the buffer pool using a hashing algorithm based on an identifier for the data set and the number of the page in the data set. When data is subsequently requested , DB2 can check the buffer pool quickly using hashing techniques. This provides efficient data retrieval. Additionally, DB2 data modification operations write to the buffer pool, which is more efficient than writing directly to DASD.

How does DB2 keep track of what data is updated in the buffer pool? This is accomplished by attaching a state to each buffer pool page: available or not available. An available buffer page meets the following two criteria:

  • The page does not contain data updated by an SQL statement, which means that the page must be externalized to disk before another page can take its place.

  • The page does not contain data currently being used by a DB2 application.

An unavailable page is one that does not meet one of these criteria because it has either been updated and not yet written to disk, or it is currently in use. When a page is available, it is said to be available for stealing. Stealing is the process whereby DB2 replaces the current data in a buffer page with a different page of data. Usually, the least recently used available buffer page is stolen first (but it depends on the stealing algorithm used for the buffer pool). DB2 provide 80 buffer pools to monitor, tune, and tweak.

Although every shop's usage of buffer pools differs , some basic ideas can be used to separate different types of processing into disparate buffer pools. Consult Table 28.1 for one possible buffer pool usage scenario. This is just one possible scenario and is not a general recommendation for buffer pool allocation.

Table 28.1. A Possible Buffer Pool Usage Scenario

Buffer Pool

Usage

BP0

Isolate system resources (DB2 Catalog and Directory, RLST, and so on)

BP1

Sequential tablespace buffer pool (usually accessed sequentially)

BP2

Sequential index buffer pool (usually accessed sequentially)

BP3

Code tables, lookup tables, and sequential number generation tables

BP4

Indexes for code tables, lookup tables, and sequential number generation tables

BP5

Dedicated buffer pool (for a single, critical tablespace or index)

BP6

Dedicated buffer pool (for an entire application)

BP7

Dedicate to sorting (DSNDB07)

BP8

Random tablespace buffer pool (usually accessed randomly )

BP9

Random index buffer pool (usually accessed randomly)

BP10

Reserve for tuning and special testing

BP11 - BP49

Additional dedicated buffer pools (per tablespace, index, partition, application, or any combination thereof)

BP8K0

Reserved for DB2 Catalog objects with 8K pages ( SYSDBASE , SYSGRTNS , SYSHIST , SYSOBJ , SYSSTR and SYSVIEWS )

BP8K1 - BP8K9

Use when 8K tablespaces have been defined

BP16K0

Reserved for DB2 Catalog objects with 16K pages ( SYSSTATS )

BP16K1 - BP16K9

Use when 16K tablespaces have been defined

BP32K s

At least one BP32K for large joins; more if 32K tablespaces are permitted; be sure to separate 32K user tablespaces from 32K DSNDB07 tablespaces


I will examine several aspects of this scenario. The first buffer pool, BP0 , should be reserved for system data sets such as the DB2 Catalog, QMF control tables, and Resource Limit Specification Tables. By isolating these resources into a separate buffer pool, system data pages will not contend for the same buffer pool space as application data pages.

graphics/v8_icon.gif

As of DB2 V8, some of the DB2 Catalog tablespaces require page sizes larger than 4K. These tablespaces use the BP8K0 and BP16K0 buffer pools.


Likewise, a single buffer pool (for example, BP7 ) can be set aside for sorting. If your environment requires many large sorts that use physical work files, isolating DSNDB07 (the sort work database) in its own buffer pool may be beneficial. This is accomplished by assigning all DSNDB07 tablespaces to the targeted buffer pool ( BP7 ).

Another technique for the allocation of buffer pools is to use separate buffer pools for indexes and tablespaces. This can be accomplished by creating tablespaces in one buffer pool (for example, BP1 ) and indexes in another (for example, BP2 ). The idea behind this strategy is to enable DB2 to maintain more frequently accessed data by type of object. For instance, if indexes are isolated in their own buffer pool, large sequential prefetch requests do not cause index pages to be flushed, because the sequential prefetch is occurring in a different buffer pool. Thus, index pages usually remain in memory longer, which increases performance for indexed access.

TUNING STRATEGY

Many organizations do not spend sufficient time tuning their buffer pools. If you do not have the time or the organizational support to highly tune your objects into separate buffer pools, at least separate the tablespaces from the indexes.

If you do nothing else with your buffer pool strategy, separating tablespaces and indexes in different buffer pools can give a nice performance boost for minimal administrative effort.


You can further tune your buffer pool usage strategy by isolating random access from sequential access. Consider using say, BP1 and BP2 for objects that are predominantly accessed sequentially, and say, BP8 and BP9 for randomly accessed objects. It is then possible to further tune the buffer pool parameters so that each type of buffer pool is optimized for the predominant type of access (that is, random or sequential).

Tables providing specialized functions can also be isolated. This is depicted by BP5 and BP6 . Because these tables are very frequently accessed, they are often the cause of I/O bottlenecks that negatively impact performance. Creating the tablespaces for these tables in a specialized buffer pool can allow the entire table to remain in memory, vastly improving online performance. Additionally, the isolation of specialized tables into their own buffer pools enables pinpoint tuning for these frequently accessed tables (and indexes). General-purpose tables (and their associated indexes) accessed by multiple programs are good candidates for this type of strategy. Following are some examples:

  • Tables used to control the assignment of sequential numbers.

  • Lookup tables and code tables used by multiple applications.

  • Tables and indexes used to control application-based security.

  • Indexes with heavy index-only access. Isolating these indexes in their own buffer pool may enable the leaf pages to remain in memory.

TUNING STRATEGY

Regardless of the number of buffer pools that your shop intends to utilize, you should consider reserving one of the 4K buffer pools for tuning and testing ( BP10 , in the example). By reserving a buffer pool for tuning, you can ALTER problem objects to use the tuning buffer pool and run performance monitor reports to isolate I/O to the problem objects. The reports can be analyzed to assist in tuning.


It is usually a wise idea to use multiple buffer pools for different types of processing. This should minimize buffer pool page contention. In the example, BP5 is used to isolate one heavily accessed tablespace and/or index in its own buffer pool. Isolating a page set this way can ensure that no other processing will steal its buffer pages. Likewise, you may want to use a single buffer pool per application, such as BP6 in the example. Isolating all of that application's objects into its own buffer pool can eliminate or reduce the instances where one application monopolizes a buffer pool to the detriment of another application using the same buffer pool. It can also make application monitoring easier because all I/O is through a single buffer pool.

The remaining buffer pools ( BP11 through BP49 ) can be used to further isolate specific objects or for further tuning.

The DB2 buffer pools have a huge impact on performance. There are several schools of thought on how best to implement DB2 buffer pools. For example, you may want to consider using separate buffer pools to do the following:

  • Separate ad hoc from production

  • Isolate QMF tablespaces used for the SAVE DATA command

  • Isolate infrequently used tablespaces and indexes

  • Isolate tablespaces and indexes used by third-party tools

CAUTION

Be careful that you do not allocate too many buffer pools. It is possible to allocate too many buffer pools to adequately manage. Be sure to align your performance needs for multiple buffer pools with your available administrative resources for monitoring and tuning those buffer pools.


One Large Buffer Pool?

The general recommendation from consultants and some IBM engineers in years past was to use only BP0 , specifying one very large buffer pool for all DB2 page sets. This strategy turns over to DB2 the entire control for buffer pool management. Because DB2 uses efficient buffer-handling techniques, the theory was that good performance could be achieved using a single large buffer pool.

In the olden days of DB2, this strategy worked fairly well. When only a few, small applications used DB2, it could manage a fairly efficient single buffer pool. Today though, only some very small DB2 implementations can get by with one large buffer pool, using BP0 and letting DB2 do the buffer pool management. The days when most shops employed the single buffer pool strategy are over. As the amount of data stored in DB2 databases increases, specialized types of tuning are necessary to optimize data access. This usually results in the implementation of multiple buffer pools. Why else would IBM provide 80 of them?

TUNING STRATEGY

Avoid using one large DB2 buffer pool. Instead, share the wealth by assigning your DB2 objects to buffer pools based on access type.


If your shop is memory constrained, or you have limited practical experience with DB2 buffer pools, you might want to consider starting with one DB2 buffer pool and then experimenting with specialized buffer pool strategies as you acquire additional memory and practical expertise.

Notes on Multiple Buffer Pool Use

The following guidelines are helpful when allocating multiple buffer pools at your shop.

Ensure That Sufficient Memory Is Available

Before implementing multiple buffer pools, be sure that your environment has the memory to back up the buffer pools. The specification of large buffer pools without sufficient memory to back them up can cause paging. Paging to DASD is extremely nasty and should be avoided at all costs.

Document Buffer Pool Assignments

Be sure to keep track of which DB2 objects are assigned to which buffer pool. Failure to do so can result in confusion. Of course, DB2 Catalog queries can be used for obtaining this information.

Modify Buffer Pools to Reflect Processing Requirements

Defining multiple buffer pools so that they are used optimally throughout the day is difficult. For example, suppose that DSNDB07 is assigned to its own buffer pool. Because sorting activity is generally much higher during the batch window than during the day, buffers assigned to DSNDB07 can go unused during the transaction processing window.

Another example is when you assign tables used heavily in the online world to their own buffer pool. Online transaction processing usually subsides (or stops entirely) when nightly batch jobs are running. Online tables might be accessed sparingly in batch, if at all. This causes the buffers assigned for those online tables to go unused during batch processing.

Unless you are using one large BP0 , it is difficult to use resources optimally during the entire processing day. Ask yourself if the performance gained by the use of multiple buffer pools offsets the potential for wasted resources. Quite often, the answer is a resounding "Yes."

DB2 provides the capability to dynamically modify the size of buffer pools using the ALTER BUFFERPOOL command. Consider using ALTER BUFFERPOOL to change buffer pool sizes to reflect the type of processing being performed. For example, to optimize the DSNDB07 scenario mentioned previously, try the following:

  • Prior to batch processing, issue the following command : -ALTER BUFFERPOOL BP1 VPSIZE( max amount )

  • After batch processing, issue the following command : -ALTER BUFFERPOOL BP1 VPSIZE( min amount )

The execution of these commands can be automated so that the appropriate buffer pool allocations are automatically invoked at the appropriate time in the batch schedule.

Buffer Pool Parameters

DB2 provides many buffer pool tuning options that can be set using the ALTER BUFFERPOOL command. These options are described in the following paragraphs.

The first parameter, VPSIZE , is arguably the most important. It defines the size of the individual virtual pool. The value can range from 0 to 400,000 for 4K buffer pools, from 0 to 200,000 for 8K buffer pools, from 0 to 100,000 for 16K buffer pools, and from 0 to 50,000 for 32K buffer pools. The total VPSIZE for all buffer pools cannot be greater than 1.6 GB. The minimum size of BP0 is 56 because the DB2 Catalog tablespaces and indexes are required to use BP0.

The capability to dynamically alter the size of a virtual pool enables DBAs to expand and contract virtual pool sizes without stopping DB2. Altering VPSIZE causes the virtual pool to be dynamically resized. If VPSIZE is altered to zero, DB2 issues a quiesce and when all activity is complete, the virtual pool is deleted.

Prior to DB2 V8, virtual buffer pools can be allocated in data spaces. To accomplish this, use the VPTYPE parameter to indicate the type of buffer pool to be used. VPTYPE(DATASPACE) indicates that data spaces are to be used for the buffer pool; VPTYPE(PRIMARY) indicates that the buffer pool is to be allocated as before, in the DB2 database services address space. You should be running in 64 bit mode to take advantage of data space buffer pools.

TUNING STRATEGY

The main reason to implement DB2 buffer pools in data spaces is to relieve storage constraints in DB2's database services (DBM1) address space. Another reason would be to provide greater opportunities for caching very large tablespaces or indexes.

Data space virtual buffer pools are no longer supported as of DB2 V8.


The sequential steal threshold can be tuned using VPSEQT . VPSEQT is expressed as a percentage of the virtual pool size ( VPSIZE ). This number is the percentage of the virtual pool that can be monopolized by sequential processing, such as sequential prefetch. When this threshold is reached, sequential prefetch will be disabled. All subsequent reads will be performed one page at a time until the number of pages available drops below the specified threshold. The value of VPSEQT can range from to 100 , and the default is 80 . When VPSEQT is set to , prefetch is disabled.

TUNING STRATEGY

If the sequential steal threshold is reached often, consider either increasing the VPSEQT percentage or increasing the size of the associated buffer pool. When sequential prefetch is disabled, performance degradation will ensue.


TUNING STRATEGY

When all of the data from tables assigned to the buffer pool can be stored in the buffer pool, and access is almost exclusively random, specify VPSEQT=0 . For example, consider specifying for VPSEQT when a virtual buffer pool is used for small code and lookup tables.


Additionally, the sequential steal threshold for parallel operations can be explicitly set using VPPSEQT . This parallel sequential steal threshold is expressed as a percentage of the nonparallel sequential steal threshold ( VPSEQT ). The value of VPPSEQT can range from to 100 , and the default is 50 .

TUNING STRATEGY

Consider isolating data sets that are very frequently accessed sequentially into a buffer pool with VPSEQT set to 95 . This enables most of the buffer pool to be used for sequential access.


TUNING STRATEGY

By setting VPPSEQT to , you can ensure that parallel I/O will not be available for this virtual pool. I am not necessarily recommending this, just pointing it out. If you want to ensure that I/O parallelism is not used for a particular buffer pool, setting VPPSEQT to will do the trick. Use caution and take care before choosing to modify this parameter.


The assisting parallel sequential threshold can be explicitly set using VPXPSEQT . This threshold sets the percentage of the parallel sequential threshold that is available to assist another parallel group member to process a query. The VPXPSEQT sequential threshold is expressed as a percentage of the parallel sequential steal threshold ( VPPSEQT ). The value of VPXPSEQT can range from to 100 , and the default is .

To understand the relationship that exists among the buffer pool parameters, refer to Figure 28.2. This diagram depicts the different parameters and thresholds and their relationships to one another.

Figure 28.2. The relationships among the buffer pool parameters.

graphics/28fig02.gif


To better understand the buffer pool parameters, consider the impact of issuing the following command:

 

 -ALTER BUFFERPOOL BP1 VPSIZE(2000) VPSEQT(80) VPPSEQT(50) VPXPSEQT(25) 

The BP1 buffer pool would be set to 8MB (2000 pages each 4KB in size). The sequential steal threshold ( VPSEQT ) is set to 80% of the buffer pool, which is 6.4MB (1600 pages). The parallel sequential steal threshold ( VPPSEQT ) is set to 50% of VPSEQT , which is 3.2MB (800 pages). Finally, the assisting parallel sequential steal threshold ( VPXPSEQT ) is set to 25% of VPPSEQT , which is .8MB (200 pages).

CAUTION

Setting these parameters can be quite confusing because they are set as percentages of other parameters. Take care to ensure that you are specifying the thresholds properly.


Deferred Write

DWQT can be used to specify the deferred write threshold. This threshold is expressed as a percentage of the virtual pool size ( VPSIZE ). It specifies when deferred writes will begin to occur. When the percentage of unavailable pages exceeds the DWQT value, pages will be written to DASD immediately (not deferred, as normal) until the number of available pages reaches 10% of ( DWQT x VPSIZE ). The value of DWQT can range from to 100 , and the default is 50 .

Additionally, VDWQT can be used to set the deferred write threshold per data set. VDWQT is expressed as a percentage of the virtual pool size ( VPSIZE ). As of DB2 V6, you can express the VDWQT threshold as an integer value instead of a percentage. When the percentage of pages containing updated data for a single data set exceeds this threshold, immediate writes will begin to occur. The value of VDWQT can range from to 90 and the default is 10 . This value should be less than DWQT .

TUNING STRATEGY

Hitting either of the deferred write thresholds does not necessarily constitute a problem. Indeed, you can use these parameters to control how DB2 writes data.

Consider setting the deferred write thresholds to enable trickle writing. With trickle writing, DB2 will regularly hit the deferred write threshold to externalize data to disk, instead of deferring writes and externalizing them all in a big bang. The pages that are written will remain in the buffer pool if they are referenced often.


Buffer Pool Page Stealing Algorithm

You can modify the page-stealing algorithm used by DB2 virtual buffer pools using the PGSTEAL parameter. When DB2 removes a page from the buffer pool to make room for a newer page, this is called page stealing . The usual algorithm deployed by DB2 uses least-recently-used (LRU) processing for managing buffer pages. In other words, older pages are removed so more recently used pages can remain in the virtual buffer pool.

However, you can choose to use a different, first-in “first-out (FIFO) algorithm. With FIFO, DB2 does not keep track of how often a page is referenced. The oldest pages are removed, regardless of how frequently they are referenced. This approach to page stealing results in a small decrease in the cost of doing a GETPAGE operation, and it can reduce internal DB2 latch contention in environments that require very high concurrency.

TUNING STRATEGY

Use the LRU page-stealing algorithm in most cases. Consider FIFO when the tablespaces and/or indexes assigned to the buffer pool are read once and remain in memory. When the buffer pool has little or no I/O, the FIFO algorithm can provide a performance boost.

Be sure to define objects that can benefit from the FIFO algorithm in different buffer pools from other objects.


Determining Buffer Pool Sizes

Many database analysts and programmers are accustomed to working with buffer pools that are smaller than DB2 buffer pools (for example, IMS and VSAM buffers). DB2 just loves large buffer pools. Each shop must determine the size of its buffer pools based on the following factors:

  • Size of the DB2 applications that must be processed

  • Desired response time for DB2 applications

  • Amount of virtual and real storage available

Remember, though, that DB2 does not allocate buffer pool pages in memory until it needs them. A DB2 subsystem with very large buffer pools might not use them all of the time.

As with the number of buffer pools to use, there are several schools of thought on how best to determine the size of the buffer pool. Actually, buffer pool sizing is more an art than a science. Try to allocate your buffer pools based on your projected workload and within the limitations defined by the amount of real and virtual memory available. Of course, for DB2 V8 you have much more flexibility in creating larger DB2 buffer pools than you had in the past due to the exploitation of 64-bit virtual memory.

The following calculation can be used as a good rough starting point for determining the size of your DB2 buffer pools:

 

 [number of concurrent users x 80] + [(desired number of transactions per second) x (average GETPAGEs per transaction)] + [(Total # of leaf pages for all indexes) x .70] 

The resulting number represents the number of 4K pages to allocate for all of your buffer pools. If you are using only BP0 , the entire amount can be coded for that buffer pool. If you are using multiple buffer pools, a percentage of this number must be apportioned to each buffer pool you are using. This formula is useful for estimating a buffer pool that balances the following:

  • Workload

  • Throughput

  • Size of the DB2 subsystem

Workload is factored in by the average GETPAGE s per transaction and the number of concurrent users. As workload (in terms of both number of users and amount of resources consumed) increases, so does the number of users and the average GETPAGE s per transaction.

Throughput is determined by the desired number of transactions per second. The size of the buffer pool increases as you increase the desired number of transactions per second. Larger buffer pools are useful in helping to force more work through DB2.

The size of the DB2 subsystem is represented by the number of index leaf pages. As the number of DB2 applications grows, the number of indexes defined for them grows also, thereby increasing the number of index leaf pages as DB2 use expands.

Recommendations for determining some of these values follow. Use the value of CTHREAD to determine the number of concurrent users. If you are sure that your system rarely reaches this maximum, you can reduce your estimate for concurrent users.

To estimate the number of transactions per second, use values from service-level agreement contracts for your applications. If service-level agreements are unavailable, estimate this value based on your experience and DB2-PM accounting summary reports.

To get an idea of overall workload and processing spikes (such as month-end processing), produce accounting summary reports for peak activity periods (for example, the most active two- hour period) across several days and during at least five weeks. Then arrive at an average for total transactions processed during that period by adding the # OCCUR from the GRAND TOTAL line of each report and dividing by the total number of reports you created. This number is, roughly , the average number of transactions processed during the peak period. Divide this number by 7200 (the number of seconds in two hours) for the average number of transactions per second. Then double this number because the workload is probably not evenly distributed throughout the course of the two hours. Also, do not use a number that is less than 10 transactions per second.

You can approximate the average number of GETPAGE s per transaction with the accounting summary or accounting detail reports (such as those provided by DB2 PM). Add all GETPAGE s for all transactions reported, and then divide this number by the total number of transactions reported . Base this estimate on transactions only ”including batch programs would cause a large overestimate. Online transactions are generally optimized to read a small amount of data, whereas batch jobs can read millions of pages.

To determine the number of leaf pages for the indexes in your DB2 subsystem, issue the following query:

 

 SELECT   SUM(NLEAF) FROM     SYSIBM.SYSINDEXES; 

For this query to work properly, RUNSTATS statistics should be up to date and any unused objects should be excluded (using a WHERE clause).

CAUTION

Keep in mind that the formula just discussed for estimating buffer pool requirements should be used as just a very rough guideline. If you have the resources at your disposal, you should carefully analyze your DB2 workload requirements by reviewing each transaction and batch program in conjunction with transaction history and your batch job schedules. You can then create a model for a typical processing day and design your buffer pool strategy to meet that model.

There are also tools on the market that can assist you in setting up and managing your buffer pools. Examples include BMC Software's Pool Advisor and Responsive Systems' Buffer Pool Tool.


DB2 Buffer Pool Guidelines

You can use the following guidelines to ensure an effective DB2 buffer pool specification at your shop.

Be Aware of Buffer Pool Thresholds

Be aware of the following overall effects of the buffer pool thresholds:

Data Manager Threshold

This is referred to as a critical buffer pool. When 95% of a buffer pool's pages are unavailable, the Buffer Manager does a GETPAGE and a release of the page for every accessed row. This is very inefficient and should be avoided at all costs.

Immediate Write Threshold

When 97.5% of a buffer pool's pages are unavailable, deferred write is disabled. All writes are performed synchronously until the percentage of unavailable pages is below 97.5%.


TUNING STRATEGY

Increase the size of your buffer pools when these thresholds are reached:

Data Manager threshold : 95%

Immediate Write threshold ( IWTH ): 97.5%

It is best to avoid reaching these thresholds because they degrade performance. (The immediate write threshold degrades performance the most.)


Be Generous with Your Buffer Pool Allocations

A buffer pool that is too large is almost always better than a buffer pool that is too small. However, do not make the buffer pool so large that it requires paging to DASD.

Monitor BP0 Carefully

The DB2 Catalog and DB2 Directory are assigned to BP0 . This cannot be changed. Therefore, even if other buffer pools are used for most of your application tablespaces and indexes, pay close attention to BP0 . A poorly performing DB2 Catalog or DB2 Directory can severely hamper system-wide performance.

graphics/v8_icon.gif

As of DB2 V8, similar precautions should be taken with BP8K0 and BP16K0 , as these buffer pools also house DB2 Catalog objects.


Allocate BP32K

Specify a 32K buffer pool ”even if you have no tablespaces in your system with 32K pages ”to ensure that joins requiring more than 4K can operate . If BP32K is not defined, at least with a minimal number of pages, joins referencing columns that add up to 4097 or greater can fail.

The default size of BP32K is 12 pages, which is small, but perhaps a good starting place if you allow large joins. Some shops avoid allocating BP32K to ensure that large joins are not attempted. Avoiding BP32K allocation is also an option, depending on your shop standards.

Be Aware of the 32K Buffer Pool Names

Remember that BP32 and BP32K are two different buffer pools. BP32 is one of the 50 4K buffer pools. BP32K is one of the 10 32K buffer pools. If you miss or add an erroneous K , you may wind up using or allocating the wrong buffer pool.

Consider Reserving a Buffer Pool for Tuning

Even if you do not utilize multiple buffer pools, consider using your unused buffer pools for performance monitoring and tuning. When a performance problem is identified, tablespaces or indexes suspected of causing the problem can be altered to use the tuning buffer pool. Then you can turn on traces and rerun the application causing the performance problem. When monitoring the performance of the application, I/O, GETPAGE s, and the usage characteristics of the buffer pool can be monitored separately from the other buffer pools.

Consider Defining a Sort Buffer Pool for DSNDB07

If you assign DSNDB07 to its own buffer pool, consider the appropriate parameters to use. First of all, the VPSEQT parameter is quite useful. Recall that VPSEQT is used to set the sequential steal threshold. Since most activity to DSNDB07 is sequential, VPSEQT should be set very high, to 95 for example. But do not set VPSEQT to 100 because not all sorting activity is sequential.

Furthermore, you can set the immediate write thresholds ( DWQT and VDWQT ) to the VPSEQT size.

NOTE

Setting the deferred write thresholds is tricky business. If you set them relatively high (for example, same as VPSEQT ) you will maintain pages in the pools and avoid writes. However, you may want to specify very low deferred write thresholds to set up trickle write. This avoids the problems that can ensue when DB2 has to write a huge amount of data because the write was deferred. Different options will work for different companies based on your processing requirements.


Finally, it is a good idea to use the BP7 buffer pool for DSNDB07 so as to minimize confusion. Because both end in the number 7, it is easy to remember that one works with the other.

Optimize BP0

BP0 is probably the single most important buffer pool in a DB2 subsystem. The system resources, namely the DB2 Catalog and DB2 Directory objects, are assigned to BP0 and cannot be moved. Therefore, many organizations decide to use BP0 to hold only these resources by failing to assign other objects to BP0 . This is a good strategy because placing other objects into BP0 can degrade the performance of processes that access the DB2 Catalog or Directory.

The size of your DB2 subsystem dictates the proper sizing of BP0 . Consider starting with a VPSIZE of 2000 pages. Monitor usage of BP0 and increase VPSIZE if access patterns warrant .

The proper specification of VPSEQT , DWQT , and VDWQT will depend on your shop's access patterns against the DB2 Catalog and Directory.

Converting Active Buffer Pool to Use Data Space

For DB2 V7, you can use data spaces for virtual buffer pools. To convert an active DB2 virtual buffer pool to use a data space, perform the following steps:

  1. Delete the active buffer pool by using ALTER BUFFERPOOL to specify VPSIZE(0) .

  2. Stop all tablespaces and indexes that are using the buffer pool.

  3. Issue the ALTER BUFFERPOOL command again specifying VPTYPE(DATASPACE) . You will also need to specify the appropriate VPSIZE for the buffer pool.

Start all of the objects that were previously stopped .

The total size of data space virtual buffer pools is limited to 32GB (for 4K page size). This limit is imposed because there is a maximum of 8 million "page manipulation blocks" in the DBM1 address space.

graphics/v8_icon.gif

Data space virtual buffer pools are no longer supported as of DB2 Version 8.


Hiperpools

graphics/v8_icon.gif

For DB2 V7 and earlier releases, you can use hiperpools to back up your virtual buffer pools. Hiperpools are no longer supported as of DB2 V8, though.


Hiperpools can be considered extensions to the regular buffer pools, which are also referred to as virtual pools. Hiperpools use hiperspaces to extend DB2 virtual buffer pools. Working in conjunction with the virtual pools, hiperpools provide a second level of data caching. When old information is targeted to be discarded from (or, moved out of) the virtual buffer pool, it will be moved to the hiperpool instead (if a hiperpool has been defined for that buffer pool).

Only clean pages will be moved to the hiperpool, though. Clean pages are those in which the data that was modified has already been written back to DASD. No data with pending modifications will ever reside in a hiperpool.

Each of the 80 virtual pools can optionally have a hiperpool associated with it. There is a one-to-one relationship between virtual pools and hiperpools. A virtual pool can have one and only one hiperpool associated with it, but it also can have none. A hiperpool must have one and only one virtual pool associated with it.

Hiperpools are page-addressable, so before data can be accessed by an application, it must be moved from the hiperpool to the virtual pool (which is byte-addressable). Hiperpools are backed by expanded storage only, whereas virtual pools are backed by central storage, expanded storage, and possibly DASD if paging occurs. The hiperpool page control blocks reside in the DBM1 address space and thus contribute to virtual storage constraints.

When you specify a virtual pool without a hiperpool, you are letting the operating system allocate the buffer pool storage required in both central and expanded memory. Keeping this information in mind, consider using hiperpools instead of specifying extremely large virtual pools without a hiperpool.

A good reason to utilize hiperpools is to overcome the 1.6GB limit for all virtual buffer pools (prior to V8). If your buffering needs exceed 1.6GB, you can specify virtual buffer pools up to 1.6GB, with larger hiperpools backing the virtual pools. Of course, you can also consider using data spaces for your virtual pools if you are running in 64 bit mode.

graphics/v8_icon.gif

Of course, the maximum buffer pool sizes were increased for DB2 V8 to the limit of the z/OS architecture, which is 1TB. (Also, the term "virtual" buffer pool is obsolete as of DB2 V8; virtual pool, virtual buffer pool, and buffer pool are all synonymous as of DB2 V8.)


TUNING STRATEGY

For pre-V8 systems, consider specifying virtual pools that will completely fit in central storage and hiperpools associated with the virtual pools. The DB2 Buffer Manager will handle the movement from expanded to central storage and should be more efficient than simply implementing a single large virtual pool. Of course, you will need to monitor the system to ensure that the virtual pool is utilizing central storage in an optimally efficient manner.

Do not over-allocate hiperpool storage. If you exceed the amount of expanded storage you have available, performance will eventually suffer.


Figure 28.3 illustrates the buffer pool to hiperpool relationship. This diagram outlines the basic functionality of hiperpools and buffer pools. Data is read from disk to central storage in the virtual buffer pool. Over time the data may be moved to the hiperpool. Once moved to the hiperpool, before it can be read again by a DB2 program, it must be moved back to the virtual buffer pool. Hiperpools are backed by expanded storage as a hiperspace. Virtual buffer pools are backed by central and expanded storage, and can possibly page to DASD for auxiliary storage.

Figure 28.3. Hiperpool to buffer pool relationship.

graphics/28fig03.gif


CAUTION

The total of all hiperpools defined cannot exceed 8GB.


Hiperpool Parameters

The ALTER BUFFERPOOL command can be used to tune hiperpool options as well as virtual pool options. The hiperpool parameter options are described in the following paragraphs.

The first option, CASTOUT , indicates whether hiperpool pages are stealable by the operating system. The value can be either YES or NO . Specifying YES enables OS/390 to discard data in the hiperpool if an expanded storage shortage is encountered . A value of NO prohibits OS/390 from discarding hiperpool data unless one of the following occurs:

  • The hiperpool is deleted

  • Hiperspace maintenance occurs

  • Hiperspace storage is explicitly released

Just as VPSIZE controls the size of virtual pools, HPSIZE is used to specify the size of each individual hiperpool. When the size of a hiperpool is altered, it immediately expands or contracts as specified. The value can range from 0 to 2,097,152 for 4K hiperpools, from 0 to 1,048,576 for 8KB hiperpools, from 0 to 524,288 for 16KB hiperpools, and from 0 to 262,144 for 32K hiperpools. The total of all hiperpools defined cannot exceed 8GB.

TUNING STRATEGY

A good starting point for HPSIZE is three times the amount of VPSIZE . If necessary, you can increase HPSIZE from there as you tune your buffer pool and hiperpool usage. Hiperpools allocated with less than three times the associated VPSIZE are usually not very efficient.


Sequential steal thresholds also can be specified for hiperpools, using the HPSEQT parameter. HPSEQT is expressed as a percentage of the hiperpool size ( HPSIZE ). It specifies the percentage of the hiperpool that can be monopolized by sequential processing, such as sequential prefetch. The value of HPSEQT can range from to 100 , and the default is 80 .

TUNING STRATEGY

If you know that the majority of your sequential prefetch requests will never be accessed again, you may want to tune your hiperpools to avoid sequential data. Do this by specifying HPSEQT=0 . This ensures that only randomly accessed data will be moved to the hiperpool.


There are no deferred write thresholds for hiperpools because only clean data is stored in the hiperpool. Therefore, pages never need to be written from the hiperpool to DASD.

Data Sharing Group Buffer Pools

If data sharing is implemented, group buffer pools are required. A group buffer pool must be defined for each buffer pool defined to each data sharing member. Data is cached from the local buffer pools to the group buffer pools during the processing of a data sharing request.

A page set is said to be GBP-dependent when two or more data sharing group members have concurrent read/write interest in it. The page set is marked as GBP-dependent during the update process and changed pages are written to the group buffer pool. GBP-dependent marking also affects DB2 Catalog and Directory page sets of the shared DB2 catalog. For GBP-dependent page sets, all changed pages are first written to the group buffer pool.

Changed data pages are written to the coupling facility at COMMIT for GBP-dependent page sets. This enables committed data to be immediately available to the other DB2 data sharing group members. It also extends the length of time it takes to commit and therefore makes it important to issue frequent COMMIT s in your programs.

The following describes a few typical operations and how a page is passed among the local and group buffer pools. The following scenario is based on a data sharing environment with two member subsystems ( DB2A and DB2B ):

  • An application in DB2A updates a column. The DB2A subsystem checks the coupling facility to determine if it should read the page from the global buffer pools or directly from disk. If DB2A determines that the page is not cached globally, it will read the page(s) from shared DASD and store the page(s) in its local buffer pool ”for example, BP6.

  • An application in DB2B wants to update the same page. A global lock (P-Lock, discussed in Chapter 23, "Locking DB2 Data") is taken indicating to the member that the page is shared. DB2A is notified and writes the changed data page to global buffer pool GBP6.

  • DB2B retrieves the page from the global buffer pools and puts it in its own BP6.

  • DB2B updates the data page and moves it back to the global buffer pool. The coupling facility invalidates the page contained in the local buffer pool for DB2A .

  • If DB2A needs to reread the data page, it will determine that the page has been marked invalid. Therefore, the page is retrieved from global buffer pool GBP6.

The GBPCACHE Parameter

The GBPCACHE clause can be specified on the CREATE and ALTER statement for tablespaces and indexes. GBPCACHE is used to indicate how the global buffer pool is to be used for a particular tablespace or index. There are two options for GBPCACHE : CHANGED and ALL .

If CHANGED is specified, and the tablespace or index has no inter-DB2 read/write interest, the group buffer pool will not be used. When an inter-DB2 read/write interest exists, only changed pages are written to the group buffer pool.

If GBPCACHE is set to ALL , changed pages are written to the group buffer pool. Clean pages are written to the group buffer pool as they are read from the shared disk.

The Castout Process

Changed data is moved from a group buffer pool to disk by means of a castout process. The group buffer pool castout process reads the pages contained in the GBP and writes them to the owning DB2's local buffer, as well as to the physical DASD devices. This process is depicted in Figure 28.4. The castout process moves data from a group buffer pool to DASD through one of the data sharing group members. This is required because there is no direct connection from a coupling facility to DASD.

Figure 28.4. The castout process.

graphics/28fig04.gif


The coupling facility is still able to update pages during the castout process. The castout process is triggered when:

  • The changed page threshold for a page set is reached.

  • The total changed page threshold for the group buffer pool is reached.

  • The group buffer pool checkpoint is reached.

NOTE

Because the coupling facility may contain data that is more recent than what is contained on the DASD devices, DB2 employs coupling facility recovery mechanisms to recover the data in case of coupling facility failure.


Data Sharing Buffer Pool Guidelines

Consider the following guidelines when specifying buffer pools for data sharing.

Select Group Buffer Pool Thresholds with Care

The castout process can have a negative impact on data sharing performance. Keep castout process execution to a minimum by carefully considering the thresholds that are related to each group buffer pool. You can control the castout process by changing the two group buffer pool thresholds:

  • The group buffer pool castout threshold determines the total number of changed pages that can exist in the group buffer pool before castout occurs. DB2 casts out a sufficient amount of data to ensure that the number of changed pages is below the threshold. The group buffer pool castout threshold is specified as a percentage of the total number of pages in the group buffer pool. The default value is 50 , which specifies that castout is initiated when the group buffer pool is 50% full of changed pages.

  • The class castout threshold also is used to control when data is cast out of a group buffer pool. DB2 internally maps modified data pages belonging to the same tablespace, index, or partition to the same castout class queues. A castout class queue is an internal mechanism used by DB2 to control the castout process for groups of page sets. When DB2 writes modified pages to the group buffer pool, it determines how many modified pages are in a particular class castout queue. When the number of modified pages for a castout class queue exceeds the threshold, DB2 casts out data pages from that queue. The castout class threshold is specified as a percentage of the total number of changed pages in the group buffer pool for a given castout class. The default for the class castout is 10 , indicating that castout is initiated when 10% of the group buffer pool contains modified pages for the class.

Do Not Underestimate the Size of the Cache Structure

The size of the group buffer pool structure has a major influence on the frequency of castout process execution. This can negatively affect performance.

The total cache structure size affects performance similar to the way that VPSIZE affects the performance of non-group buffer pools (virtual pools). In addition, the less memory allocated to the group buffer pool, the more frequent the castout process.

The number of directory entries also affects performance. A directory entry contains control information for one page regardless of the number of places that page is cached. There is a one-to-one correspondence between cached physical data pages and directory entries. If a page is in the group buffer pool and in the virtual buffer pools of two members, there is only one directory entry for the page. Each directory entry is 208 bytes for 4K pages and 264 bytes for 32K pages. A directory entry is used by the coupling facility to determine where to send cross- invalidation signals when a page of data is changed or when that directory entry must be reused. The higher the write-to-read ratio, the more directory entries are needed.

The final impact on performance is the number of data entries. Data entries are the actual places where the data page resides. The greater the number of distinct pages that are cached, the more directory entries are needed.

Use Partitioned Tablespaces

Design for parallel processing by using partitioned tablespaces for data that is accessed in a data sharing environment. This encourages the use of Sysplex query parallelism. DB2 performs effective parallel processing only when data is partitioned.

Consider Group Buffer Pool Duplexing

Use group buffer pool duplexing to make recovery easier. Without duplexing, your only options for recovery in the event of a group buffer pool failure were to recover the group buffer pool or to rebuild it. With duplexing, a secondary group buffer pool is available on standby in another coupling facility. The secondary group buffer pool can take over if the primary group buffer pool fails.

With a duplexed group buffer pool, you have two allocations of the same group buffer pool that use one logical connection. One allocation is called the primary structure, the other is the secondary structure. The primary structure is used for cross-invalidation and page registration, and it is the structure from which changed data is cast out to DASD. When changes are written to the primary structure, they are written to the secondary structure, as well.

IRLM Tuning Options

Until now, I have covered tuning options for the DB2 database address space and system services address space. You also can tune the IRLM address space.

When the IRLM is started, several parameters can be specified in the JCL for the IRLM. These options can have a significant effect on DB2 performance.

DEADLOK

Indicates when the IRLM executes a deadlock detection cycle. The IRLM must check for deadlocks frequently to avoid long waits for resources that will never be made available.

ITRACE

Indicates whether an IRLM trace will be started.

PC

Indicates where IRLM locks will be stored in memory.


TUNING STRATEGY

A good starting value for the DEADLOK parameter is 15 seconds. However, this parameter should be evenly divisible into the IRLMRWT DSNZPARM value to ensure synchronization between IRLM deadlock detection and DB2 timeout waits.


TUNING STRATEGY

Never issue an IRLM trace for an IRLM used by DB2. Specify ITRACE=NO . The IRLM trace rapidly degrades performance and does not provide much useful information.


TUNING STRATEGY

Specify PC=NO . This guarantees that cross memory services are not used for DB2 locking. Instead, locks are stored in ECSA and are directly addressable. This will optimize the locking performance.

Before using ECSA to store IRLM locks, though, be aware that ECSA is not protected and an erratic system task can potentially overwrite ECSA storage.


 <  Day Day Up  >  


DB2 Developers Guide
DB2 Developers Guide (5th Edition)
ISBN: 0672326132
EAN: 2147483647
Year: 2004
Pages: 388

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net