DB2 Server for VSE & VM: Control Center Operations Guide for VM


Chapter 33. Automated DBSPACE Maintenance Tools


Overview

Within the database, the OPTIMIZER uses catalog statistics to choose the best path to the data within the database. Due to the overhead involved, the database does not automatically update this statistical data during normal database update activity. Without reasonably accurate statistics, the optimizer can choose a less efficient method of retrieving data, reducing the overall database performance. It is therefore the responsibility of the DBA to assure that statistics are updated on a regular basis so that database performance will be maximized.

Another common database problem which impacts performance is the gradual fragmentation and poor organization of data over a period of time. After many inserts, updates, and deletes, the data within a database will become spread over many physical pages, with many gaps in between and with the physical sequence of data different than the logical sequence of data. Periodic reorganization is required to pack the data on the minimum number of physical pages and in a logical sequence that optimizes data retrieval.

The Automated DBSPACE Maintenance tools are known collectively as the SQLMAINT program with its associated functions. They are part of the Database Administration tools. The purpose of the Automated DBSPACE Maintenance tools is to provide a means to automatically monitor DBSPACES and perform maintenance upon them to improve performance. These tools are designed for automatic execution on a scheduled basis on a Control Center support machine, performed at a routine interval with a selected set of parameters.

There are two types of DBSPACE maintenance tools: Statistics Maintenance and DBSPACE Reorganization Maintenance. This chapter explains the steps needed to install SQLMAINT, then explains the function and use of each of the two types of tools.

SQLMAINT jobs should not be scheduled to execute on the service machine, since all automated operations functions with all databases will be disabled while the maintenance functions execute.

Before You Begin

Use SQLMAINT during non-peak hours to prevent locking contention with other users of the database. Due to the intensive updating of the database system catalogs, use of this tool during periods of high database use can lead to lock contention.

The parameters used when SQLMAINT is executed will determine the number of DBSPACES that will have maintenance applied. These parameters should be carefully selected to assure that maintenance does not run into peak database use periods.

How the Automated DBSPACE Maintenance Tools Work

SQLMAINT automates the UPDATE STATISTICS and the REORGANIZATION processes for a database by keeping track of these activities at the DBSPACE-level and executing these functions where required based on specified execution parameters.

SQLMAINT performs a detailed analysis of each DBSPACE to determine the degree of need for reorganization. The results of this analysis are provided in a hardcopy report for study by the DBA. SQLMAINT can be optionally instructed to automatically reorganize one or more DBSPACES based on the degree of need determined by the analysis. The number of DBSPACES reorganized can be limited by specified quantities or elapsed time limits.

By setting up SQLMAINT to run on a regular schedule, database maintenance can be performed automatically during periods of low database use (e.g., at night or on weekends). SQLMAINT uses a database table to maintain use information for each DBSPACE in the database. When SQLMAINT executes, each DBSPACE is considered for maintenance based on parameters specified by you for that particular execution. After execution, the information within the SQLMAINT table is updated to reflect the changes which have occurred.

When a maintenance function of SQLMAINT is invoked, these steps are performed:

  1. Link and establish database communications to the target database.
  2. Verify that the user has DBA authority.
  3. Refresh the SQLMAINT table with new data from SYSTEM.SYSDBSPACES.
  4. Select a list of DBSPACES based on selection parameters.
  5. Create the report or perform the maintenance as specified.
  6. Update the SQLMAINT table for each maintained DBSPACE.

Who Can Use the Automated DBSPACE Maintenance Tools

Use of these tools requires Control Center database Administration-level or greater authorization.


Installing the Automated DBSPACE Maintenance Tool for Operation

You must have database DBA connect authorization to install the SQLMAINT tool into each target database using the install function of the SQLMAINT panel interface. These steps are required to install the SQLMAINT too. They must be completed for each database where SQLMAINT will run. A detailed description of each step follows.

  1. Make SQLMAINT's files available to subsequent users.
  2. Acquire a public DBSPACE in which the tool is to be installed.
  3. Run the Install option from the Control Center panel interface.

Step 1. Make SQLMAINT's Files Available to Subsequent Users

The SQLMAINT tool consists of these files, which must be placed on a CMS minidisk available to SQLMAINT users:
Note:These files are part of the Control Center code and reside on the Control Center service machine's code disk, which is typically accessible to users.

Filename
Description

SQLMAINT EXEC
Master tool which performs the maintenance activities.

SQLMAIN$ XEDIT
XEDIT macro which generates a parameter entry panel.

SQLMAINX XEDIT
XEDIT macro used in generating panels.

SQLMAINT HELPCMS
CMS help file for SQLMAINT.

SQLREORG EXEC
Actual execution of the reorganization function will require all files belonging to the DBSPACE Reorganization tool, including the DBINIT CONTROL file.

Step 2. Acquire a Public DBSPACE in which the Tool is to be Installed

The installation procedure will create a public table within the database (SQLMAINT.SQLMAINT_TABLE). A public DBSPACE must be acquired and available prior to invoking the install process. The DBSPACE name can be any valid database name.

The required size of the public DBSPACE will vary depending on the number of DBSPACES within the target database. The SQLMAINT_TABLE will contain a row for each acquired DBSPACE in the database, which will be used to maintain information about reorganizations done against those DBSPACES using the SQLMAINT tool.

Step 3. Run the Install Option from the Control Center Panel Interface

Refer below to DBSPACE Maintenance Utility Panel.

Invoke the panel interface (SQM) of the Control Center; choose Option U (Database Utilities); then Option M (SQLMAINT). At the ensuing panel, select Option I (Install); fill in the database name and then press PF10 to initiate the installation process.

The SQLMAINT installation process will create a public table in the target database as shown in Figure 199. In addition, a row for each non-system-owned DBSPACE will be entered into this table during the install process.

Figure 199. SQLMAINT Table Definition


CREATE TABLE "SQLMAINT"."SQLMAINT_TABLE" (
  "OWNER"          CHAR(8)        NOT NULL
 ,"DBSPACENAME"    VARCHAR(18)    NOT NULL
 ,"DBSPACENO"      SMALLINT       NOT NULL
 ,"FREEPCT"        SMALLINT       NOT NULL
 ,"PCTINDX"        SMALLINT       NOT NULL
 ,"UPSTAT_DATE"    CHAR(7)        NOT NULL
 ,"UPSTAT_TIME"    CHAR(8)        NOT NULL
 ,"UPSTAT_ELAPSED" SMALLINT       NOT NULL
 ,"REORG_DATE"     CHAR(7)        NOT NULL
 ,"REORG_TIME"     CHAR(8)        NOT NULL
 ,"REORG_ELAPSED"  SMALLINT       NOT NULL
 ,"REORG_FREEPCT"  SMALLINT       NOT NULL
 ,"REORG_PCTINDX"  SMALLINT       NOT NULL
 ,"REORG_STATUS"   CHAR(2)        NOT NULL
 ,"REORG_WEIGHT"   SMALLINT       NOT NULL
 ,"NPAGES"         INTEGER        NOT NULL
 ) IN "PUBLIC"."SQLMAINT";

SQLMAINT Control Table

When SQLMAINT is installed on a database, a control table will be created in a public DBSPACE to store information about maintenance activities. This control table can be used as a basis for creating maintenance reports and can also be updated manually to further control the maintenance process (such as changing the reorganization dates to prevent a large DBSPACE from being reorganized automatically).

The name of the control table defaults to SQLMAINT.SQLMAINT_TABLE unless the SQLOWNER and SQLTNAME variables at the beginning of the SQLMAINT EXEC are changed at your installation. The columns of this table are:




Column Name
Description

OWNER
Owner of the DBSPACE (from SYSTEM.SYSDBSPACES)

DBSPACENAME
Name of the DBSPACE (from SYSTEM.SYSDBSPACES)

DBSPACENO
DBSPACE number (from SYSTEM.SYSDBSPACES)

FREEPCT
FREEPCT value (from SYSTEM.SYSDBSPACES)

PCTINDX
PCTINDX value (from SYSTEM.SYSDBSPACES)

UPSTAT_DATE
Date of the last UPDATE STATISTICS

UPSTAT_TIME
Time of the last UPDATE STATISTICS

UPSTAT_ELAPSED
Elapsed time of the last UPDATE STATISTICS

REORG_DATE
Date of the last SQLREORG

REORG_TIME
Time of the last SQLREORG

REORG_ELAPSED
Elapsed time of the last SQLREORG in minutes

REORG_FREEPCT
FREEPCT value of the last SQLREORG

REORG_PCTINDX
PCTINDX value of the last SQLREORG

REORG_STATUS
A two-character indicator of SQLREORG success

REORG_WEIGHT
An integer weight of SQLREORG need

NPAGES
Size of the DBSPACE

The SQLMAINT.SQLMAINT_TABLE can be viewed at any time to examine the results of SQLMAINT activities. For a discussion of how to use this table, see Using the SQLMAINT Control Table. The SQLMAINT_TABLE is refreshed each time the SQLMAINT function is executed. If you run SQLREORG, the SQLMAINT_TABLE will also be updated. For example:

Column Name
DBSPACE Attribute

FREEPCT
ALTER PCTFREE

PCTINDX
PCTINDEX (current)

REORG_FREEPCT
PCTFREE used to create the DBSPACE

REORG_PCTINDX
PCTINDEX (current)

SQLMAINT Installation Output Example

Shown below is example output from the SQLMAINT installation process.

Figure 200. SQLMAINT Installation Output Example


 
SQLMAINT version V6.1 03/16/98 13:28:56
INSTALL function executing...
Enter a public DBSPACEname for the installation
(Or just press ENTER to cancel)
tools
03/16/97 13:29:04 Dropping old SQLMAINT.SQLMAINT_TABLE...
03/16/97 13:29:05 Creating new SQLMAINT.SQLMAINT_TABLE...
13:29:06 Refreshing SQLMAINT.SQLMAINT_TABLE...
13:29:06 Deleting SQLMAINT.SQLMAINT_TABLE names not on SYSTEM.SYSDBSPACES...
13:29:06 Refreshing data from SYSTEM.SYSDBSPACES...
13:29:06 0 SQLMAINT.SQLMAINT_TABLE rows updated from SYSTEM.SYSDBSPACES
13:29:06 Get DBSPACE names not in SQLMAINT.SQLMAINT_TABLE...
13:29:57 85 rows from SYSTEM.SYSDBSPACES added to SQLMAINT.SQLMAINT_TABLE
SQLMAINT INSTALL completed
SQLMAINT ended 03/16/97 13:29:58
Ready; T=3.01/4.97 13:29:58

The SQLMAINT install function primes the SQLMAINT_TABLE with entries of all private and non-system-owned public DBSPACES. All date and time columns are set to zeroes. The table is now ready for use by the other functions of SQLMAINT.


DBSPACE Maintenance Utility Panel

The entry panel of the Automated DBSPACE Maintenance tools is shown in Figure 201.

Figure 201. Automated DBSPACE Maintenance Tools Entry Screen

+--------------------------------------------------------------------------------+
|***********************   DBSPACE MAINTENANCE UTILITY    ************** ********|
|                                                                                |
|  FUNCTION ==>  LS      ( I, LS, US, LR, RP, RR ) - (Install, List Statistics,  |
|                --       Update Statistics, List Reorg Candidates,              |
|                         Reorg using Prior List, Run Reorgs - Re-evaluate)      |
|  DATABASE ==>  SQMDBA                                                          |
|                --------                                                        |
|  -----------------------------  Options  --------------------------------      |
|  DBSPACE OWNER ==> ALL                  (ALL, PUBLIC, PRIVATE, ownername)      |
|                    ------------------                                          |
|  DBSPACE NAME  ==>                      (blank for ALL, use % for wildcard)    |
|                    ------------------                                          |
|  SEQUENCE      ==> WEIGHT (AGE, WEIGHT)   DAYS SINCE  ==> 14                   |
|                    ------                                 ---                  |
|  TIME LIMIT    ==> 180    (Minutes)       QTY LIMIT   ==> 10     (Max. Run Qty)|
|                    -----                                  -----                |
|  STOP ON FAIL  ==> NO     (YES or NO)     REPREP PKGS ==> YES    (YES/NO)      |
|                    ---                                    ---                  |
|  PAGES: MIN    ==> 0     MAX   ==> 999999    COMMITCOUNT ===> 0                |
|                                    -------                    -------          |
|  FILEMODE    ==>    (Reorg work disk)      ALLSTATS  ==> NO   (YES/NO)         |
|                                                                                |
|  PF1 HELP  PF3 QUIT   PF6 SCHED   PF8 SEL CRITERIA   PF9 VIEW TAB   PF10 PROCES|
+--------------------------------------------------------------------------------+

Most fields are initialized to some values. The first two parameters (FUNCTION and DATABASE) are required. They will identify what function you want to perform and what database the function will be performed upon. These fields are initialized to LS and SQLDBA, respectively. However, if you are currently initialized to a database, that name will appear in the DATABASE field.

Display Fields

Functions

The function field can have these values:

Function
Description

Install (I)
This should only be used once, when SQLMAINT needs to be installed into a new database. If this function is used again, all previous maintenance data will be erased.

List Statistics (LS)
This function lists DBSPACES which need to have statistics updated. It will produce a report but will not perform any maintenance.

Update Statistics (US)
This function will perform UPDATE STATISTICS on DBSPACES that meet the specified criteria.

List Reorg Candidates (LR)
This function will list candidate DBSPACES that require reorganization based on specified criteria. It will produce a report but will not perform any maintenance.

Reorg using Prior List (RP)
This function will reorganize DBSPACES based on candidates chosen by a previous evaluation list (generated either by the LS or RR function). The previous candidate list must be available on the A-disk in file database SQLMAINT. The essential purpose of this option is to allow one execution of the candidate evaluation process using either LS or RR, with subsequent multiple reorganization runs based on the single prior evaluation. This can save considerable DBSPACE examination time, but should be used with caution since the evaluation data can quickly become invalid.

Run Reorgs - Reevaluate (RR)
This function will reorganize candidate DBSPACES that meet the specified criteria. It will search all DBSPACES designated by the criteria looking for candidates, generate a list of the candidates and perform the reorganizations.

Options

The parameters below the line labeled "Options" allow you to control the maintenance functions by restricting the number and type of DBSPACES that will be selected.

Parameter
Description

DBSPACE OWNER
Can be used with the LS, US, LR, and RR functions to specify whether PUBLIC, PRIVATE, ALL, or specific DBSPACE owner(s) will be selected for analysis. The database wildcard character (%), can be used at the beginning or end of a specified DBSPACE OWNER to select like DBSPACE OWNER names.

DBSPACE NAME
Can be used with the LS, US, LR, and RR functions to specify a DBSPACE name or group of similar DBSPACE names that should be selected for analysis. The database wildcard character (%), can be used at the beginning or end of a specified DBSPACE name to select like DBSPACE names. This parameter defaults to ALL if not specified.

SEQUENCE
Is only applicable to the RR function and controls the order in which the selected DBSPACES will be reorganized. AGE will perform reorganization on DBSPACES sequenced according to the last date that each DBSPACE was reorganized (oldest to newest). WEIGHT will perform reorganization according to a calculated weight which indicates how much each DBSPACE needs the maintenance. WEIGHT is the default if this parameter is not specified.

DAYS SINCE
Applicable to the LS, US, LR, and RR functions. It is the primary method of controlling the automated execution of maintenance activities. It specifies the number of days since the previous UPDATE STATISTICS or REORGANIZATION that must have passed before the same maintenance will be performed again on a DBSPACE.

TIME LIMIT
Applicable to the US, RR, and RP functions. This limit the number of minutes during which maintenance will be performed. After this time limit has passed, SQLMAINT will not begin maintenance on any new DBSPACE candidates but will complete maintenance on any DBSPACE that is currently in process. The default is 180 minutes (3 hours).

QTY LIMIT
Applicable to the US, RR, and RP functions. Will limit the number of DBSPACES that will be maintained.

STOP ON FAILURE
Applicable to the RR and RP functions. Enter YES if SQLMAINT should STOP if a DBSPACE reorganization fails; enter NO if SQLMAINT should continue with subsequent DBSPACE reorganizations if a failure occurs.

REPREP PKGS
Applicable to the RR and RP functions. Enter NO if SQLREORG should not reprep (or rebind) the access modules (packages) when doing a DBSPACE reorganization. The default is YES, which means reprepping (rebinding) will occur.

DBSPACE PAGES
Applicable to the LS, US, LR, and RR functions, the MINIMUM and MAXIMUM DBSPACE sizes (expressed in pages) can be specified to limit the DBSPACES selected for analysis.

COMMITCOUNT
Applicable to the RR and RP functions. Allows you to specify a value from 1 to 2147483647 to be used in the RELOAD processing. A value of 0 means to disregard the parameter.

FILEMODE
Applicable to the RR and RP functions. This optional parameter is used to specify a minidisk, linked in WRITE mode, that should be used as work space for the unloaded DBSPACE data for reorganizations. The default is to acquire and use a temporary disk for the DBSPACE and to use the 191 A-disk for the DBSU file and listing file.

ALLSTATS
Applicable to the RR and RP functions. When doing DBSPACE reorganization maintenance (SQLREORG), you can choose to have it generate the UPDATE ALL STATISTICS DBSU command if this parameter is set to YES. Otherwise, the default UPDATE STATISTICS command is used.

PF Keys

The PF Keys offer these options:

PF Key
Description

SEL CRITERIA (PF8)
Use this key to view the selection criteria which will be used for determining whether the DBSPACES selected by the main panel options also meet the criteria for being selected as a reorganization candidate. You can also change any of the criteria options to affect the selection process.

VIEW TAB (PF9)
Choose this key to view the SQLMAINT table entries.


Statistics Maintenance Tool

The Statistics Maintenance tool consists of the List Statistics and Update Statistics functions.

How the Statistics Maintenance Tool Works

The main objective of this tool is to choose DBSPACES which need to have UPDATE STATISTICS run based upon the criteria supplied to the tool.

A list of candidates is supplied with the LS option. The US option actually runs the UPDATE STATISTICS utility (SQLDBSU) and maintains the history in the SQLMAINT_TABLE. By using the Job Scheduling tool, the Statistics Maintenance tool can be scheduled to run on a regular basis to cycle through the list of DBSPACES on some determined schedule. Optionally, the job can be scheduled to run on selected DBSPACES after analyzing the report.

List Statistics (LS)

This function is chosen by specifying the LS option on the SQLMAINT entry panel. The purpose of this function is to create a list of DBSPACES, based upon the input parameters specified, which need to have UPDATE STATISTICS run.

The output of this run is file "database USTATnnn A", where nnn depends on the DBSPACE OWNER value entered. If ALL was chosen, then nnn=ALL. If PUBLIC was entered, then nnn=PUB. If PRIVATE was entered, then nnn=PRI. If another value was entered, then nnn equals the first three characters of the value. This file is in the format of an SQLDBSU input file with commands to update statistics for the DBSPACES chosen by SQLMAINT. The file can therefore be used as input to a stand-alone DBSU run if desired. Refer to the DB2 Server for VSE & VM Database Services Utility manual for more information on this utility.

Update Statistics (US)

This function is chosen by specifying the US option on the SQLMAINT entry panel. The purpose of this function is to run the UPDATE STATISTICS on the DBSPACES chosen according to the parameters supplied.

The output of this run is file "database USTATnnn A" (see LS function above), which is the input to the SQLDBSU to perform the UPDATE STATISTICS on the selected DBSPACES. Another file, SQMINSRT USTATLOG A, will contain the results of the run. The function is either performed at your terminal (PF10) or can be scheduled for later execution (PF6).

Examples of the two files are shown in Figure 202.

Figure 202. Update Statistics DBSU File

COMMENT '************************************************************'
COMMENT '******** Update Statistics for DBSPACEs on SQLDBA  *********'
COMMENT '********** OPTIONS: DBSPACEs: PRIVATE.ALL, min=0, **********'
COMMENT '**********     max=4097, days=14, qty=5, time=30 ***********'
COMMENT '************************************************************'
UPDATE ALL STATISTICS FOR DBSPACE "MSTRUSR1"."DBSPNAM1";
COMMIT WORK;
UPDATE SQLMAINT.SQLMAINT_TABLE SET UPSTAT_DATE = '97110',
UPSTAT_TIME = '10:47:25'
     WHERE OWNER = 'MSTRUSR1' AND DBSPACENAME = 'DBSPNAM1';
COMMIT WORK;
COMMENT '********************************************'
UPDATE ALL STATISTICS FOR DBSPACE "MSTRUSR2"."DBSPNAM2";
COMMIT WORK;
UPDATE SQLMAINT.SQLMAINT_TABLE SET UPSTAT_DATE = '97110',
UPSTAT_TIME = '10:47:25'
     WHERE OWNER = 'MSTRUSR2' AND DBSPACENAME = 'DBSPNAM2';
COMMIT WORK;
COMMENT '********************************************'
UPDATE ALL STATISTICS FOR DBSPACE "MSTRUSR3"."DBSPNAM3";
COMMIT WORK;
UPDATE SQLMAINT.SQLMAINT_TABLE SET UPSTAT_DATE = '97110',
UPSTAT_TIME = '10:47:25'
     WHERE OWNER = 'MSTRUSR3' AND DBSPACENAME = 'DBSPNAM3';
COMMIT WORK;
COMMENT '********************************************'
UPDATE ALL STATISTICS FOR DBSPACE "MSTRUSR4"."DBSPNAM4";
COMMIT WORK;
UPDATE SQLMAINT.SQLMAINT_TABLE SET UPSTAT_DATE = '97110',
UPSTAT_TIME = '10:47:25'
     WHERE OWNER = 'MSTRUSR4' AND DBSPACENAME = 'DBSPNAM4';
COMMIT WORK;
COMMENT '********************************************'
UPDATE ALL STATISTICS FOR DBSPACE "MSTRUSR5"."DBSPNAM5";
COMMIT WORK;
UPDATE SQLMAINT.SQLMAINT_TABLE SET UPSTAT_DATE = '97110',
UPSTAT_TIME = '10:47:25'
     WHERE OWNER = 'MSTRUSR5' AND DBSPACENAME = 'DBSPNAM5';
COMMIT WORK;
COMMENT '********************************************'
COMMENT '********************************************'
COMMENT '*** DBSPACES needing update = 10 ****'
COMMENT '********************************************'
COMMENT '*** DBSPACES to update this run = 5 ****'
COMMENT '********************************************'

In the preceding figure, Figure 202, ten DBSPACES were eligible for maintenance; however, only five were done since a QTY LIMIT of five was specified.

Figure 203. Update Statistics Report File

                 Update Statistics for DBSPACEs on SQLDBA
                             03/16/97 10:47:29
 
                       DBSPACEs: PRIVATE.ALL, min=0,
                      max=4097, days=14, qty=5, time=30
 
10:47:52 MSTRUSR1.DBSPNAM1 UPDATE STATISTICS completed successfully
10:48:16 MSTRUSR2.DBSPNAM2 UPDATE STATISTICS completed successfully
10:48:18 MSTRUSR3.DBSPNAM3 UPDATE STATISTICS completed successfully
10:48:36 MSTRUSR4.DBSPNAM4 UPDATE STATISTICS completed successfully
10:48:38 MSTRUSR5.DBSPNAM5 UPDATE STATISTICS completed successfully
10:48:38 SQLMAINT UPDATE STATISTICS function completed

Note that the panel input values are listed in the report. Here, all private DBSPACES were to be considered, but only five were chosen. A time limit of 30 minutes was allocated to the job, and only DBSPACES up to 4097 pages were considered. Only those DBSPACES which had had statistics updated at least 14 days ago were considered.


DBSPACE Reorganization Maintenance Tool

The DBSPACE Reorganization Maintenance tool consists of the List Reorg Candidates function (LR), Run Reorg function (RR) and the Run Reorg Prior (RP) function.

How the DBSPACE Reorganization Maintenance Tool Works

The main objective of this tool is reorganization candidate selection. The selection function is a two step process. First, a list of potential DBSPACES is selected from the SQLMAINT table based upon the options entered on the Automated DBSPACE Maintenance entry panel. Second, this list is checked against the selection criteria in effect that determine whether a particular DBSPACE needs reorganizing. The DBSPACE selection options have been covered above. The selection criteria are described next.

DBSPACE Maintenance Criteria Selection Screen

Shown in Figure 204 is the Criteria Selection screen for the Automated DBSPACE Maintenance tool.

Figure 204. Automated DBSPACE Maintenance Selection Criteria Screen

+--------------------------------------------------------------------------------+
|***********************   DBSPACE MAINTENANCE UTILITY    ************** ********|
|                                                                                |
|  DATABASE => SQMDBA          CRITERIA  SELECTION  SCREEN                       |
|                                                                                |
| -------------- CRITERIA DERIVED FROM SYSTEM CATALOG: (QUICK RETRIEVAL) ------- |
|                                                                                |
|  CRITERIA 1: Y UNCLUSTERED INDEX   OR    CLUSTER RATIO LESS THAN               |
|              -                         -                         ----          |
|                                                                                |
|  CRITERIA 2: Y OVERFLOW ROWS >  10 %        (Specify Y or N)                   |
|              -                  --                                             |
|                                                                                |
| -------------- CRITERIA DERIVED FROM SHOW DBSPACE: (LONGER RETRIEVAL) -------- |
|  Y USE CRITERIA 3 thru 6 (Y or N)                                              |
|  -                                                                             |
|  CRITERIA 3: DATA or INDEX PAGES > 70 % USED                                   |
|                                    --                                          |
|  CRITERIA 4: PROPORTION of USED DATA/INDEX PAGES                               |
|  ipg used > 40 % AND dpg used < 40 %  OR dpg used > 40 % AND ipg used < 40 %   |
|             --                  --                  --                  --     |
|  CRITERIA 5: DATA PAGES FREE SPACE > 35 % AND DATA PAGES USED > 25 %           |
|                                      --                         --             |
|  CRITERIA 6: EMPTY DATA or INDEX PAGES  >  5 % of TOTAL DATA or INDEX PAGES    |
|                                           --                                   |
| PF1 HELP PF3 QUIT PF6 SET TO DEFAULTS PF7 RET TO PRIOR SCREEN  PF10 PROCESS    |
|                                                                                |
+--------------------------------------------------------------------------------+

The Automated DBSPACE Maintenance tool provides for user selected maintenance criteria parameters. With this panel, you can choose which criteria to use, as well as adjust any of the values of a specific criterion.

There are currently six criteria which are evaluated by SQLMAINT, any one of which can cause a DBSPACE to be selected for reorganization:

  1. The existence of unclustered primary indexes on tables within the DBSPACE or the CLUSTERRATIO field value reaching a designated value for any index within the DBSPACE. This will typically occur when many inserts and deletes are performed over time, and it will greatly reduce the performance of the database.
  2. The existence of over 10% of overflow pages for any table within the DBSPACE. This condition indicates a great deal of fragmentation caused by inserts and will considerably increase the number of I/O operations required to return selected rows.
  3. The condition of over 70% of available data pages or index pages being occupied. The reorganization process can better pack data on each occupied page and reduce the number of DBSPACE pages required.
  4. An imbalance between the fullness of the data pages and index pages. Each DBSPACE reserves a certain percentage of its allocated pages for indexes which can or can not provide the proper proportion of data and index pages after actual DBSPACE use. SQLMAINT will detect any imbalance and will calculate the correct proportion to be used during the reorganization process.
  5. The existence of a lot of free space on each DBSPACE page and a large number of pages used. The DBSPACE will normally reserve a certain percentage of each data page for later insert activity, allowing the data to remain clustered. If the number of pages increases considerably and the reserved space within each page is not being used for inserts, then SQLMAINT will request a reorganization which will reduce the percentage of each page that is reserved for inserts.
  6. The existence of empty data or index pages in excess of 5% of total DBSPACE data pages or index pages.

The Search Criteria are divided into 2 groups:

A. Those obtained from the database System Catalogs
B. Those obtained with the SHOW DBSPACE command

Group A criteria afford a quicker determination of a DBSPACE's candidacy and result in a faster SQLMAINT execution. Group B criteria use the SHOW DBSPACE command for each selected DBSPACE to obtain relevant data against which to match the criteria values to determine DBSPACE candidacy.

Each Group's criteria are discussed below. Note that any criterion can be used in conjunction with any other criterion. Criterion 1 offers a choice between 2 index type tests. If no criteria are modified or specified directly by the DBA, the defaults will be used. The defaults are set originally by the menu. Subsequent modification to any values and choices will be retained the next time SQLMAINT is invoked. To reset to the default values, bring up the CRITERIA SELECTION panel and press PF6 to restore to default values.

Figure 205. SQLMAINT DBSPACE Selection Criteria

        ***************  GROUP A CRITERIA    ***************
 
CRITERION 1:  UNCLUSTERED INDEX    or    CLUSTER RATIO LESS THAN nnnn
 
              This criterion affords a choice of either using
unclustered index occurrences within the DBSPACE OR specifying a
CLUSTERRATIO value (0001-9999) to determine candidates for reorganization.
The 2 choices are mutually exclusive - one or the other can be specified.
Either can be used in conjunction with other criteria.
              CLUSTER RATIO LESS THAN nnnn is the value which the
CLUSTERRATIO field in the catalog must be below in order to have the
DBSPACE be picked as a candidate for reorganization regardless of the
value of the CLUSTER field.  If this field is blank, then the UNCLUSTERED
INDEX criterion is used and a weight of 1 is assigned if a table has an
index which is W (no longer clustered).  If the CLUSTER RATIO field has
a value entered, a weight of 1 is assigned if any table's CLUSTERRATIO
field value is below the value specified in this parameter, regardless
of CLUSTER field value.
 
              The DEFAULT criterion is UNCLUSTERED INDEX.
 
-------------------------------------------------------------------------
 
CRITERION 2:  OVERFLOW ROWS > nn %  (10% is default)
 
              Specifying this criterion will cause SQLMAINT to check
the number of rows in overflow and determine whether the percentage
specified in the selection criterion is equal to or greater than the
actual percentage calculated from the catalog.
 
              The DEFAULT is 10%.
 
-------------------------------------------------------------------------
 
        ***************  GROUP B CRITERIA    ***************
 
  Specifying a Y in the USE CRITERIA 3 through 6 field will cause
SQLMAINT to employ all GROUP B criteria when determining candidate
selection.  Specifying an N will cause SQLMAINT to use only those
criteria which have values specified in their parameter fields.
 
              The DEFAULT is Y (use all Group B criteria)
 
 
CRITERION 3:  DATA or INDEX PAGES > nn % USED   (70% is default)
 
              This criterion checks the percentage of currently occupied
data and index pages.  If the percentage equals or exceeds the value
specified, the DBSPACE is considered a candidate for reorg.
 
              The DEFAULT is 70%.
 
-------------------------------------------------------------------------
 
CRITERION 4:  PROPORTION of USED DATA/INDEX PAGES   nn % (40% is default)
 
              Specifying a value for this criterion will cause
SQLMAINT to do these checks to determine candidacy:
 
   a. If index pages used is GREATER THAN nn %      AND
          data pages used is LESS    THAN nn %
   b. If data  pages used is GREATER THAN nn %       AND
         index pages used is LESS    THAN nn %
 
   A match on either of the above results in candidacy.
 
              The DEFAULT is 40%.
 
-------------------------------------------------------------------------
 
CRITERION 5:  DATA PAGES FREE SPACE > nn %  AND  (nn default is 35%)
              DATA PAGES USED       > xx %       (xx default is 25%)
 
              This criterion checks the percentage of data pages free
space for greater than nn%.  If met or exceeded, it checks the percentage
specified (xx %) of data pages used.  If both match or exceed the values
specified, the DBSPACE is considered a candidate.
 
              The DEFAULT is 35% for nn, and 25% for xx.
 
-------------------------------------------------------------------------
 
CRITERION 6:  EMPTY DATA or INDEX PAGES > nn % of TOTAL DATA or INDEX
              PAGES.
 
              This criterion checks the percentage of empty data or
index pages for nn %.  If met or exceeded, the DBSPACE is considered a
candidate.
 
              The DEFAULT is 5% for nn.
 

The PF Keys offer these options:

PF Key
Description

Help Screen (PF1)
Displays the HELP SCREEN which explains the selection criteria.

Quit (PF3)
Is the QUIT or EXIT key which ends SQLMAINT processing.

Set to Defaults (PF6)
Resets the criteria's default values.

Ret to Prior Screen (PF7)
Returns you to the main SQLMAINT entry panel.

Process (PF10)
This key processes any changes made to the panel criteria selections and values and begins the process of DBSPACE candidate selection based upon the main panel choices and the criteria selected.

SQLMAINT TABLE List Screen

Shown in Figure 206 is the SQLMAINT Table list screen for the Automated DBSPACE Maintenance tool.

Figure 206. SQLMAINT Table List Screen

+--------------------------------------------------------------------------------+
| mm/dd/yyyy                     CONTROL CENTER                       hh:mm:ss   |
|*----------------------  DBSPACE MAINTENANCE UTILITY   ----------------------*  |
||  Database => SQMDBA                                                        |  |
||                                UPSTATS      REORGANIZATION                 |  |
|| OWNER     NAME               LAST   ELAP  LAST   ELAP  STAT  WGHT  NPAGES  |  |
|| -------- ------------------  -----  ----  -----  ----  ----  ----  ------- |  |
|| C370451  C370451             97073     0  97073     1    00     1     1024 |  |
|| M356959  M356959A            97094     0  97094     2    00     1     1024 |  |
|| M760595  M760595B            00000     0  00000     0           1     1024 |  |
|| M997990  M997990A            97074     0  97074     0    00     1     1024 |  |
|| PUBLIC   DBEDB00             97016     1  00000     0           2     2048 |  |
|| PUBLIC   DSQTSCT1            97035     0  97035    11           1     4097 |  |
|| PUBLIC   DSQTSCT2            95334     0  95336     7           1     4097 |  |
|| PUBLIC   DSQTSCT3            97041     0  97037    27           1     8064 |  |
|| PUBLIC   DSQTSDEF            97071     0  00000     0           1     4097 |  |
||                                                                            |  |
||                      The fields in RED are modifiable                      |  |
||                                                                            |  |
||                                                                            |  |
||                              Page 1     of 3                               |  |
|*----------------------------------------------------------------SQMMAIN3----*  |
|PF:  1 Help        3 EXIT          4 Maint Panel    7 Bkwd         8 Fwd        |
|     9 Sort/Wght  10 Sort/Udate   11 Sort/Rdate  12 Sort/Rstat   ENTER UPDATE   |
|                                                                                |
+--------------------------------------------------------------------------------+

Pressing PF9 from the main SQLMAINT entry panel will provide you with the rows from the SQLMAINT_TABLE which are retrieved according to the options present on the screen. For the LS and US options, the rows which meet the UPSTAT_DATE parameter (DAYS SINCE) will be presented (the rows must also meet the other parameters selected, such as MIN-MAX pages). For the LR, RR, and RP options, the rows which meet the REORG_DATE parameter (DAYS SINCE) will be presented.

From the screen which is presented, you can sort the report by various fields. You can also update certain fields which would then subsequently alter the candidate list chosen when you finally begin the candidate selection process.

For a full explanation of the new SQLMAINT Table Display screen, enter HELP SQLMNT3 at a CMS command prompt. This is the same information which is presented when you press PF1 from the Table Display List screen.

List Reorg Candidates (LR)

This function is chosen by specifying the LR option on the SQLMAINT entry panel. The purpose of this function is to create a list of DBSPACES, based upon the input parameters specified, which need to be reorganized.

The output of this run is three files:

database REOPICKS A
Contains a list of DBSPACES picked for reorganization. It is used internally by SQLMAINT.

database SQLMAINT A
Contains a list of DBSPACES picked for reorganization. It is used internally by SQLMAINT when running the Reorg using Prior List function.

database nnnREOLS A
The nnn is dependent upon the DBSPACE type picked (see "List Statistics (LS)" above). This file is the actual report generated showing the status of the candidate DBSPACES which were examined for reorganization potential.

Shown in Figure 207 is an example of the reorganization analysis report created by SQLMAINT. This report is saved in a file on the user's 191 A-disk. The filename of the report will be the database name and the filetype will be descriptive of the subset of the database analyzed (the filetype of the example is PRIREOLS, indicating that private DBSPACES were considered for analysis).

In this report, nine private DBSPACES were analyzed and three were selected for reorganization, while one was discounted since it only met criterion 5 (space USER2.DBSPACE2). Note that the others had never been reorganized, since their date/time fields were 0. They happened to be new entries in the SQLMAINT_TABLE. The report was sequenced by DBSPACE name since this was only a report run.

Based on the analysis, DBSPACE MSTRUSR1.DBSPNAM1 will be reorganized first because it has a weight of 2. Weight is calculated by adding the number of unclustered indexes to the number of other reorganization criteria which caused this DBSPACE to be chosen.

The next reorganization will be performed on the DBSPACE with the next highest WEIGHT, and so on.

Figure 207. SQLMAINT List Reorg Candidates Report

                  DBSPACE REORGANIZATION CANDIDATES REPORT
                          Database: VMSYSTM1.SQLDBA           03/16/97 13:57:00
 
            OPTIONS: DBSPACEs: PRIVATE.ALL, seq=DBSPACE, min=0,
                    max=999999, days=14, qty=10, time=180
 
  DBSPACES EXAMINED = 9
  **************************************************************
  CRITERIA 1 = DBSPACES with Tables with index type W
 
  CRITERIA 2 = DBSPACES with Tables with NOVERFLOW rows >= 10%
 
  CRITERIA 3 = DBSPACES with data or index pages > 70% used
 
  CRITERIA 4 = DBSPACES with index pages used > 40% and data pages < 40%
               -- OR -- with data pages used > 40% and index pages < 40%
 
  CRITERIA 5 = DBSPACES with data pages free space > 35%
               -- AND --  data pages used > 25%
 
  CRITERIA 6 = DBSPACES with empty data or index pages > 5%
                        of DBSPACE data pages or index pages
****************************************************************************
MSTRUSR1.DBSPNAM1              DBSPACENO: 59       LAST REORG: 00000 00:00:00
       Criteria 1:  2 indexes unclustered
                           NBR PAGES  OCCUPIED PAGES   %FREE  EMPTY
                    HEADER:      8      1 (    12%)     81%
                    DATA:      679    190 (    27%)     22%    0
                    INDEX:     337     24 (     7%)     48%    2
           WEIGHT = 2,    DBSPACE PAGES = 1024
****************************************************************************
MSTRUSR2.DBSPNAM2              DBSPACENO: 71       LAST REORG: 00000 00:00:00
       Criteria 4:  PCTINDX: Old=20, Suggested=20
                           NBR PAGES  OCCUPIED PAGES   %FREE  EMPTY
                    HEADER:      8      1 (    12%)     83%
                    DATA:      812    437 (    53%)     12%    0
                    INDEX:     204      0 (     0%)      0%    0
           WEIGHT = 1,    DBSPACE PAGES = 1024
   This DBSPACE will NOT be REORGED, the evaluation indicates
   that a reorganization is not currently needed.
****************************************************************************
MSTRUSR3.DBSPNAM3              DBSPACENO: 179      LAST REORG: 00000 00:00:00
       Criteria 1:  1 index unclustered
                           NBR PAGES  OCCUPIED PAGES   %FREE  EMPTY
                    HEADER:      8      1 (    12%)     97%
                    DATA:     1733      3 (     0%)     13%    0
                    INDEX:     307      2 (     0%)     67%    0
           WEIGHT = 1,    DBSPACE PAGES = 2048
****************************************************************************
MSTRUSR4.DBSPNAM4              DBSPACENO: 180      LAST REORG: 00000 00:00:00
       Criteria 1:  1 index unclustered
                           NBR PAGES  OCCUPIED PAGES   %FREE  EMPTY
                    HEADER:      8      1 (    12%)     97%
                    DATA:     1733      3 (     0%)     13%    0
                    INDEX:     307      2 (     0%)     67%    0
           WEIGHT = 1,    DBSPACE PAGES = 2048

Run Reorg Prior Function (RP)

This function is chosen by specifying the RP option on the SQLMAINT entry panel. The purpose of this function is to run reorganizations using a previously created list of reorganization candidates in a file named dbname SQLMAINT A).

This option is identical to the RR option, except that DBSPACES are not evaluated; the file containing previously evaluated DBSPACES is used as input to DBSPACE selection.

The output of this run is two files:

database RUNREOLS A
This file is a report of the reorganized DBSPACES.

database SQLMAINT A
This file is edited by removing the entries which were reorganized in this run. When all entries are deleted, the file is also erased.

Shown in Figure 208 is an example of the reorganization execution report generated by SQLMAINT. This report is saved in a file on the user's 191 A-disk. The filename of the report will be the database name and the filetype will be RUNREOLS.

The reorganization report shows the before and after statistics for the DBSPACE and the results of the reorganization (provided as a status code defined at the end of the report).

Figure 208. Example SQLMAINT DBSPACE Reorganized Report

                         DBSPACE REORGANIZATION REPORT
                            Database: VMSYSTM1.SQLDBA            03/16/97 15:10:01
 
                                 ELAPSE
OWNER    DBSPACENAME        SPNO TIME   ST W DATA STATISTICS      INDEX STATISTICS
________ __________________ ____ ______ __ _ _______________      ________________
 
 
MSTRUSR1 DBSPNAM1             59 2.38   00 2 679 190(27%) 22%     337 24(7%) 48%
                         ****** After REORG: 679 190(27%) 22%     337 24(7%) 48%
 
MSTRUSR3 DBSPNAM3            179 1.66   00 1 1733 3(0%) 13%       307 2(0%) 67%
                         ****** After REORG: 1733 3(0%) 13%       307 2(0%) 67%
 
 
 
Number of DBSPACES successfully reorged =  2
 
Total elapsed time for all reorgs = 4.04 minutes
 
 
                     End of Report for  PDEVDBA  REORG JOB
 
NOTE : SPNO  - DBSPACE number
       ELAPSE- elapsed time, in minutes, for the REORG
       W     - weight factor of the DBSPACE reorged
       ST    - status of the REORG
               '00' Good Reorg
               'XX' Good Reorg but space should be increased
               'CC' Good Reorg but selection criteria did not change
               'NN' Reorg not done because space should be increased
               'SS' Not enough unload disk space for reorg
               'TT' Not enough time left to reorg this space
               '99' Bad Reorg
       DATA/INDEX BEFORE - the results of a SHOW DBSPACE
                command before the REORG was done, format:
                    tttt uu(pp%) ff%
                where:  tttt is total pages,
                        uu   is pages used,
                        pp   is percent of pages used,
                        ff   is avg. percent free per page.
       DATA/INDEX AFTER  - the results of a SHOW DBSPACE
                command after the REORG was done

Run Reorg Function (RR)

This function is chosen by specifying the RR option on the SQLMAINT entry panel. The purpose of this function is to evaluate the DBSPACES to create a list of reorganization candidates, then to run reorganization on them according to the specified input parameters.

The output of this run is three files:

database REOPICKS A
This file is a list of DBSPACES picked for a reorganization. It is used internally by SQLMAINT.

database nnnREOLS A
The nnn is dependent upon the DBSPACE type picked (see "List Statistics (LS)" above). This file is the actual report generated showing the status of the candidate DBSPACES which were examined for reorganization potential. It is identical to the report produced by the RS function, except that SEQ will either be WEIGHT or AGE, depending on the option chosen on the entry panel. See Figure 207.

database RUNREOLS A
This file is a report of the reorganized DBSPACES. It is identical to the report generated by the RP function. See Figure 208.


Additional Topics

Automated Execution

SQLMAINT has been designed for repeated execution on a scheduled basis using information in the SQLMAINT table that is created in each database. Since this table will initially have no history of maintenance on each DBSPACE, all DBSPACES will be considered when SQLMAINT is executed the first time. For the List Reorg Candidates (LR) and Run Reorgs (RR) functions, this can take a considerable amount of time (each DBSPACE will be scanned). To reduce the number of DBSPACES scanned, update the SQLMAINT table manually.

Examples

To update statistics on the SQLDBA database for a maximum of 50 private DBSPACES per night, with a maximum run time of one hour, and selecting DBSPACES that have not had maintenance for three weeks, this statement could be executed each night from a disconnected virtual machine:




 
SQLMAINT SQLDBA UPSTATS ( PRIVATE QTY=50 TIME=60 DAYS=21

To reorganize DBSPACES on the TESTDBA database for a maximum of 10 private DBSPACES per night, with a maximum run time of three hours, selecting DBSPACES in sequence according to the most need, and only considering DBSPACES that have not been reorganized within the last month, this statement could be executed each night from a disconnected virtual machine:




 
SQLMAINT TESTDBA RUNREORG ( PRIVATE WEIGHT QTY=10 TIME=180 DAYS=30

Reorganization Work Space

The reorganization process will require disk space to hold the unloaded DBSPACE data until each DBSPACE is dropped and reacquired. It is your responsibility to assure that enough disk space is available to hold all DBSPACES that will be reorganized during a single SQLMAINT execution. If the default temporary disk option is selected, each DBSPACE reorganization will acquire a temporary disk to hold the unloaded data and will drop the temporary disk when the reorganization has completed successfully. This option uses the 191 A-disk to hold the DBSU command file and the DBSU output listing file. These files can be large, so enough 191 disk space should be provided.

When a linked disk is specified for SQLMAINT use (with the FILEMODE entry), the disk will be used for all reorganization activity. This includes the unloaded DBSPACE, the DBSU command file, and the DBSU output listing file. These files will not be erased after the reorganization completes, so this disk must be large enough to hold files for all DBSPACE reorganizations that will be performed during a single execution of SQLMAINT.

Using the SQLMAINT Control Table

The SQLMAINT Control Table can be altered by the Control Center Administrator to control the selection process of the SQLMAINT tool.

If a database has a large number of DBSPACES, the REORG_DATE and UPSTAT_DATE columns in the SQLMAINT table can initially be set to different values so that a single SQLMAINT run will only scan a portion of the DBSPACES. For instance, you can execute a database command such as:




 
UPDATE SQLMAINT.SQLMAINT_TABLE SET UPSTAT_DATE = '99001', REORG_DATE
= '99001' WHERE OWNER < 'M'

This can change about half of the DBSPACES to a different maintenance date. You could then invoke SQLMAINT with an appropriate DAYS SINCE parameter so that only those DBSPACES would be selected. By using the TIME LIMIT and/or QTY LIMIT parameters, you could further restrict the number of DBSPACES that would be maintained until the SQLMAINT table developed a maintenance history.

The REORG_STATUS parameter can also be changed to NN to prevent a DBSPACE from being selected for reorganization.

Summary Comments


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]