Running reorg on a DB2 database

You can reorganize indexes on a table by rebuilding the index data into unfragmented, physically contiguous pages. Reorganizing indexes and tables reduce the time that is required to resolve a query and retrieve data that match the query filter.

Before you begin

You must retrieve organizational information about the database with the reorgchk command. For more information about retrieving DB2® database statistics, see Running reorgchk on a DB2 database.

About this task

You must use the database statistics to determine whether the tables and indexes require reorganizing. The time that is required to reorganize a table depends on the DB2 database size. Reorganizing a table takes more time than updating statistics. Therefore, it is best to update statistics first and confirm whether it improves database performance. Usually, data in LDAP is accessed by index, reorganizing tables is not as beneficial as reorganizing indexes.

Procedure

  1. Log in with the directory server instance owner credentials.
  2. Connect to the database.
    db2 connect to ldapdb2
    
    where, ldapdb2 is the database name.
  3. To reorganize the indexes and table in the database, run the appropriate command that is based on your requirement:
    • To reorganize the tables with an asterisk in the last column, run the following command:
      db2 reorg table table_name 
      where, table_name is the name of the table to be reorganized. For example, LDAPDB2.LDAP_ENTRY.
    • To reorganize a table to match the order of a particular index, run the following command:
      db2 reorg table table_name index index_name
      where, index_name is the name of the index. For example, LDAPDB2.SNI.
    • To reorganize the indexes with an asterisk in the last column, run the following command:
      db2 reorg index index_name