A database index is a set of pointers, logically ordered on a column or set of columns in a table, that exist to provide faster access and force uniqueness of rows within a table. Indexes are stored on index pages in the same DBSPACE as their associated tables. Control information about indexes is stored on header pages in the DBSPACE.
Extensive modifications to a table can fragment its indexes. This can lead to increased I/O and execution time whenever those indexes are used.
The Index Reorganization tool automates index maintenance by analyzing the indexes in your databases and/or reorganizing those that can benefit from it. You can select the indexes to be examined by:
To invoke the Index Reorganization tool through the panel interface,
To invoke the Index Reorganization tool directly from the CMS READY prompt:
Note: |
---|
|
Indexes are reorganized using these methods:
Note: |
---|
System catalog table indexes are analyzed BUT NOT REORGANIZED. Use Control Center's system catalog index reorganization utility to reorganize system catalog indexes. (Option RC on the Database Utility Functions menu). |
The product index reorganizations run in multiple user mode (with the database up). They may execute on your own virtual machine or on a support machine. Remember that you or the support machine must be either the owner of the index or have DBA authority in the target database.
The Index Reorganization tool:
The Index Reorganization tool uses the system catalogs to access information about an index. It calculates the number of pages that each index should occupy according to the guidelines given in Appendix "A" of the DB2 Server for VSE & VM Database Administration manual. Only valid, active indexes, primary keys, and unique constraints are considered in these calculations. The total of all calculated index pages is then compared to the actual number of pages the indexes occupy in the DBSPACE (from SHOW DBSPACE). If indexes occupy more than the calculated number of pages, the indexes in that DBSPACE are considered candidates for reorganization.
Two ranking factors are used to assign a relative need of reorganization for the indexes in a DBSPACE. They are:
(Actual index pages - calculated index pages) / total index pages
Actual index pages - calculated index pages
Indexes in DBSPACES with higher ranking factors are reorganized first.
Note: |
---|
|
To execute the Index Reorganization tool in command mode, the syntax is:
>>-+-SQLRINDX--------------------+----------------------------->< '-dbname function--(--option--' |
where:
If no parameters are specified, the Index Maintenance Utility Screen is displayed.
The Control Center Index Maintenance Utility Screen is shown in Figure 196. The first two parameters, FUNCTION and DATABASE, are required. They identify the function you want to perform and the database against which you want to perform it. If you are initialized to a database, that name will appear in the DATABASE field.
Depending on the function selected, the parameters below the line labeled "Options" will allow you to limit the scope of candidate selection and set time or quantity based execution limits.
Figure 196. Index Maintenance Utility Screen
+--------------------------------------------------------------------------------+ |************* SQLRINDX - DATABASE INDEX MAINTENANCE UTILITY ************** | | | |FUNCTION ==> LI LI - List Index Reorg Candidates | | -- IP - Reorg Indexes using Prior List | | RI - Evaluate and Reorg Indexes | | | |DATABASE ==> SQLDBA | | -------- | | ----------------------------- Options ------------------------------ | |DBSPACE OWNER ==> SQLDBA ( ALL, PUBLIC, PRIVATE, ownername ) | | ------------------ | |DBSPACE NAME ==> ( blank for ALL, use % for wildcard ) | | ------------------ | | | | | |TIME LIMIT ==> 180 (Minutes) QTY LIMIT ==> 10 (Max. Run Qty) | | ----- ----- | | | | | |DBSPACE PAGES: MINIMUM ==> 0 MAXIMUM ==> 999999 | | ------- ------- | | PF1 HELP PF3 QUIT PF6 Schedule PF10 Process Immediately | +--------------------------------------------------------------------------------+
Each Index Reorganization function generates report and output files which are stored on the service machine for that database. Refer to Files and Reports for a description of these files. The function field can have these values:
These options apply in panel interface as well as command mode.
Command mode syntax: OWNer=
Command mode syntax: DBSPname=
Command mode syntax: TIME=
Command mode syntax: QTY=
Command mode syntax: DBMIN=, DBMAX=
Each index reorganization function generates report and output files which are created on the virtual machine where the Index Reorganization is run and sent to the service machine for that database.
The index reorganization files remain on the "A" disk of the user or Control Center support machine and the Control Center service machine. The files on the service machine are used for future index maintenance and to ensure that:
Each file used in the Index Reorganization process is described below:
The figure which follows is an example of a DBSPACE Index Reorganization Candidates Report.
Figure 197. DBSPACE Index Reorganization Candidates Report
DBSPACE INDEX REORGANIZATION CANDIDATES REPORT
Dbname: WMAVM1.SQL34DBA CNTRLID: SQMSTTS1
03/13/97 08:43:58
OPTIONS: Dbspaces: ALL.ALL, min=0, max=999999,
qty=3, time=180
DBSPACES EXAMINED = 23
**************************************************************
CRITERIA 1 = Percent of Index Pages to be Reclaimed by Reorg
CRITERIA 2 = Number of Index Pages to be Reclaimed by Reorg
****************************************************************************
ANDYS.ANDYS DBSPACENO: 9
NBR PAGES OCCUPIED PAGES %FREE EMPTY
SHOW DBSPACE INDEX: 200 100 ( 50%) 98% 0
CALCULATED INDEX: 50 ( 25%)
RECLAIM: 50 ( 25%)
Index reorganization candidate
****************************************************************************
RAYM.RAYM DBSPACENO: 12
NBR PAGES OCCUPIED PAGES %FREE EMPTY
SHOW DBSPACE INDEX: 84 17 ( 20%) 45% 0
CALCULATED INDEX: 17 ( 0%)
RECLAIM: 0 ( 0%)
Actual occupied index pages are less than/equal
calculated index pages. Indexes will NOT be reorganized
*************************************************************************
PUBLIC.SYS0001 DBSPACENO: 1
NBR PAGES OCCUPIED PAGES %FREE EMPTY
SHOW DBSPACE INDEX: 7680 4433 ( 57%) 61% 0
CALCULATED INDEX: 113 ( 0%)
RECLAIM: 4320 ( 56%)
WARNING: This DBSPACE contains system indexes.
Only the non-system indexes in this dbspace will
be reorged by SQLRINDX. Use CTRLCTR Reorganize
Catalog Index tool to reorganize System catalog indexes.
Index reorganization candidate.
******* THERE ARE 2 CANDIDATES FOR REORGANIZATION *****
In the example above, all 23 DBSPACES in the database were included. QTY= 3 was specified so analysis ceased after the third DBSPACE. Two DBSPACES were identified as candidates for index reorganization.
The figure which follows is an example of a DBSPACE Index Reorganization Report.
Figure 198. DBSPACE Index Reorganization Candidates Report
DBSPACE INDEX REORGANIZATION REPORT
Database: WMAVM1.SQL34DBA 03/13/97
11:33:50
ELAPSE CALC
OWNER DBSPACENAME SPNO TIME ST W1 W2 IPGS INDEX STATISTICS
_____ __________________ ____ ______ __ ____ ____ ____ ________________
ANDYS ANDYS 9 0.01 00 0% 0 50 200 100(50%) 98%
****** After REORG: 200 50(25%) 98%
Number of dbspaces successfully reorged = 1
Total elapsed time for all reorgs = 1.00 minute
End of Report for SQL34DBA INDEX REORG JOB
NOTE : SPNO - dbspace number
ELAPSE- elapsed time, in minutes, for the REORG
W1 - Percent of index pages reclaimed by reorg
W2 - Number of index pages reclaimed by reorg
CALC IPGS - Number of pages indexes should occupy
ST - status of the REORG
'00' Good Reorg
'CC' Good Reorg but calculated index pages
were under estimated
'SY' Good Reorg but System Catalog Indexes
in this Dbspace were not Reorged
'TT' Not enough time left to reorg this space
'XX' Bad Index Reorgs occurred in this dbspace
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