Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Setting the Volume to Eleven - Tuning DB2 Configuration Parameters

Blair AdamacheIBM Canada
Blair Adamache is a seventeen-year veteran of the IBM Toronto Lab. He bought his first RDBMS (10base, the predecessor to FoxPro) in 1986, but then joined IBM Database Technology the following year so he could play with database software without paying for it. He can be reached at adamache@ca.ibm.com

Summary:  DB2 answer man Blair Adamache offers some useful hints on using and tracking DB2 configuration parameters.

Date:  01 Apr 2002
Level:  Introductory
Also available in:   Japanese

Activity:  2700 views
Comments:  

Introduction

Counting instance configuration parameters, database configuration parameters and registry variables, DB2® gives you over 300 global settings to control your database. The intent is not to blind you with parameters, but to give you detailed control, if you need it, over how the database performs and consumes operating system resources.

Consider the fictional and satirical band Spinal Tap, which was known more for high-volume rock and roll more than high IQ, and who believed that if the volume setting on their amplifier went up to 11, it would be 10% louder than amplifiers that went to 10. With DB2, on the other hand, it is really possible to achieve high performance without turning everything up to 11. The purpose of this article, when used in conjunction with the DB2 Administration Guide , will show you how to do it.


The basics

To start, don't panic at the thought of 300 parameters; many of them are fixed when the instance or the database is created (such as the database territory, code page, code and country code). Others, such DIAGLEVEL and DIAGPATH, can stay at their default unless you need to troubleshoot. And, for the vast majority of performance-oriented configuration parameters, you can have DB2 recommend a value by running the Performance Wizard from the Control Center:


Figure 1: Configuring a database using the Performance Wizard
Configuring a database using the Performance Wizard

Database configuration parameters apply to the database (I'll use the famous SAMPLE database for the rest of this article in examples). Database manager configuration parameters apply to all databases created under that instance. If I run the db2ilist command, I can see the instances on the machine:


C:\dbm>db2ilist

DB2CTLSV DB2

Registry variables generally apply to all DB2 instances running on the machine. They are described in an Appendix of the Administration Guide. You set them by running db2set. For example, the following db2set command enables hash join on all DB2 instances:

db2set db2_hash_join=yes

The command db2set -lr lists all available registry variables. You display a value's setting by running db2set with no argument. For example, the following command tells you the name of the default DB2 instance on Windows:

C:\dbm>db2set db2instdef
DB2

Display the settings of database manager parameters with this command:

DB2 GET DATABASE MANAGER CONFIGURATION 

A shorter form of the above command is:

DB2 GET DBM CFG

Display the settings of database configuration parameters with this command:

	DB2 GET DATABASE CONFIGURATION FOR <<dbname>>

A shorter form of the above command is:

DB2 GET DB CFG FOR SAMPLE


Dynamic and static configuration parameters

In DB2 Version 7, most database manager configuration parameters are static: you have to change them and restart DB2 to have them take effect. Most database configuration parameters require all applications to disconnect from and reconnect to the database to take effect. IBM understands the awkwardness of this, and most DB2 configuration parameters will become dynamic in a future release, allowing you to see the results of changing them immediately. In Version 7, examples of dynamic configuration parameters include:

  • At the instance level, the default database system monitor switches (dft_monswitches)
  • At the database level, the number of commits to group (mincommit)

Tracking changes in configuration parameters

When you run your hardware and software with systems management discipline you only make a change when you can monitor the effect and know how to back it out if the effect makes the system worse. Because making multiple changes at the same time can make restoring desired behavior complicated, some systems management disciplines advocate changing only one thing at a time.

If you were happy with the way DB2 is running, but then encounter an unexplained problem, when you contact IBM for help, you might be asked: "What was the last thing you changed?" DB2 can help here. For example, the DB2DIAG.LOG is a record of interesting DB2 events. DB2 also has tracing, logs, an Event Monitor, and for backup and restore, a History file.

To track what's changed in the database manager and database configurations, you can create a table to store historical values for each. In the example below, I've added an identity column as well, and will show how it can be used further on:

CREATE TABLE DBMCFG 
       (CFGPARM VARCHAR(254) NOT NULL,
        VALUE VARCHAR(254),
        CAPTURE_TSTMP TIMESTAMP NOT NULL WITH DEFAULT,
        ITERATION INT GENERATED ALWAYS AS IDENTITY)

CREATE TABLE DBCFG 
      (CFGPARM VARCHAR(254) NOT NULL,
       VALUE VARCHAR(254),
       CAPTURE_TSTMP TIMESTAMP NOT NULL WITH DEFAULT, 
       ITERATION INT GENERATED ALWAYS AS IDENTITY)

These tables allow you to record the values of configuration parameters at points in time. Note that if DB2 is never stopped, most of the database manager parameters (apart from the first iteration of each) may not apply, because they are static. Similarly, if DB2 has never been stopped and one or more applications have stayed connected, changes to database configuration parameters will not yet be effective. Knowing the parameter values at a point in time might help debug problems stated like this: "Performance was good on Wednesday, and then it got bad on Thursday even though we had fewer users on the system."

If you remember to capture all values to these two tables whenever you change a configuration parameter, you'll be able to see if DB2 and application behavior changes are related to configuration parameter settings. Capturing the values is shown with two IMPORT commands below. Making these parts of a script that starts DB2 can automate this record keeping. Each IMPORT command is preceded by writing the configurations to a file (all of this can be done in a C program using the DB2 interfaces described in the Administrative API Reference):

  1. Here is how I write the configurations to a file:
    DB2 GET DBM CFG>DBMCFG.OUT
    DB2 GET DB CFG FOR SAMPLE>DBCFG.OUT
    

  2. Below is how I capture the values into the table. The IMPORT command reads the contents of the *.OUT files and inserts the ASCII lines as rows into the two tables created above:
    DB2 IMPORT FROM DBMCFG.OUT OF ASC METHOD L ( 2 81,60 314 ) INSERT INTO DBMCFG
    DB2 IMPORT FROM DBCFG.OUT OF ASC METHOD L ( 2 81,60 314 ) INSERT INTO DBCFG
    

Note that the value of the configuration value is stored in both the CFGPARM and VALUE columns. It's stored by itself in the VALUE column so that we can use it for calculations. The VALUE column is so wide because some parameters, such as the location of logs, allow an absolute path, which can be quite long. If these tables grow large, consider a unique index on the combination of CFGPARM and INTERATION:

       CREATE UNIQUE INDEX CFGPARM_ITERATION ON DBCFG 
(CFGPARM,ITERATION)

Now a simple query can list everything that's changed. This query depends on knowing that there are 76 database parameters, but this will vary by the DB2 product and release you are running. Similarly, the number will be lower for the smaller database manager configuration (around 112 parameters). We'll use the TIME and DATE functions to turn the timestamp into something easier to read, and order by these columns:

SELECT CFGPARM, VALUE, TIME(CAPTURE_TSTMP), DATE(CAPTURE_TSTMP)     
FROM DBCFG
      WHERE ITERATION>76 AND 
      CFGPARM NOT IN 
      (SELECT CFGPARM FROM DBCFG WHERE ITERATION<77)
      ORDER BY 4,3

The NOT IN is used to compare recent values against their original values. Like any sample code you get, if you have more ambition than the author, you can devise something quite valuable. For example, the Administration Guide groups some parameters by the types of memory they consume:

  • Database shared memory
  • Application shared memory
  • Agent private memory
  • Agent/application communication memory
  • Database manager instance memory

If in the *.OUT files above, if you strip out special characters, the numeric values for memory configuration values can be stored in numeric fields and used to calculate the amounts of the five kinds of memory above. This, like many interesting questions you can ask yourself about your own use of DB2, is left as an exercise for the reader.


About the author

Blair Adamache is a seventeen-year veteran of the IBM Toronto Lab. He bought his first RDBMS (10base, the predecessor to FoxPro) in 1986, but then joined IBM Database Technology the following year so he could play with database software without paying for it. He can be reached at adamache@ca.ibm.com

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=14440
ArticleTitle=Setting the Volume to Eleven - Tuning DB2 Configuration Parameters
publish-date=04012002
author1-email=
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers