Optimizing File Size: The REBUILD Subcommand

In this section:

How to:

You use the REBUILD subcommand for one of two reasons. Primarily, you use it to improve data access time and storage efficiency. After many deletions, the physical structure of your data does not match the logical structure. REBUILD REBUILD dumps data into a temporary work space and then reloads it, putting instances back in their proper logical order. A second use of REBUILD REBUILD is to delete segment instances according to a set of screening conditions.

Normally, you use the REBUILD subcommand as a way of maintaining a clean data source. To check if you need to rebuild your data source, enter the ? FILE command (described in Confirming Structural Integrity Using ? FILE and TABLEF):

? FILE filename

If your data source is disorganized, the following message appears:

FILE APPEARS TO NEED THE -REBUILD-UTILITY
REORG PERCENT IS A MEASURE OF FILE DISORGANIZATION
0 PCT IS PERFECT -- 100 PCT IS BAD
REORG PERCENT x%

This message appears whenever the REORG PERCENT measure is more than 30%. The REORG PERCENT measure indicates the degree to which the physical placement of data in the data source differs from its logical, or apparent, placement.

The &FOCDISORG variable can be used immediately after the ? FILE command and also shows the percentage of disorganization in a data source. &FOCDISORG will show a data source percentage of disorganization even if it is below 30% (see the Developing Applications manual).


Top of page

x
Procedure: How to Use the REBUILD Subcommand

The following steps describe how to use the REBUILD subcommand:

  1. Initiate the REBUILD facility by entering:
    REBUILD

    The following options are available:

    1. REBUILD        (Optimize the database structure)
    2. REORG          (Alter the database structure)
    3. INDEX          (Build/modify the database index)
    4. EXTERNAL INDEX (Build/modify an external index database)
    5. CHECK          (Check the database structure)
    6. TIMESTAMP      (Change the database timestamp)
    7. DATE NEW       (Convert old date formats to smartdate formats)
    8. MDINDEX        (Build/modify a multidimensional index)
  2. Select the REBUILD subcommand by entering:
    REBUILD or 1
  3. Enter the name of the data source to be rebuilt.

    Enter the ddname.

  4. If you are simply rebuilding the data source and require no selection tests, enter:
    NO

    The REBUILD procedure will begin immediately.

    On the other hand, if you wish to place screening conditions on the REBUILD subcommand, enter:

    YES

    Then enter the necessary selection tests, ending the last line with ,$.

    Test relations of EQ, NE, LE, GE, LT, GT, CO (contains), and OM (omits) are permitted. Tests are connected with the word AND, and lists of literals may be connected with the OR operator. A comma followed by a dollar sign (,$) is required to terminate any test.

    For example, you might enter the following:

    A EQ A1 OR A2 AND B LT 100 AND
    C GT 400 AND D CO 'CUR',$

Statistics appear when the REBUILD REBUILD procedure is complete, including the number of segments retrieved and the number of segments included in the rebuilt data source.


Top of page

x
Using the REBUILD Subcommand

The following examples illustrate how to use the REBUILD subcommand.



Example: Using the REBUILD Subcommand

The following example illustrates using the REBUILD subcommand interactively.

rebuild
 
Enter option
1. REBUILD       (Optimize the database structure)
2. REORG         (Alter the database structure)
3. INDEX         (Build/modify the database index)
4. EXTERNAL INDEX(Build/modify an external index database)
5. CHECK         (Check the database structure)
6. TIMESTAMP     (Change the database timestamp)
7. DATE NEW      (Convert old date formats to smartdate formats)
8. MDINDEX       (Build/modify a multidimensional index)
rebuild
ENTER NAME OF FOCUS/FUSION FILE
> employee
ANY RECORD SELECTION TESTS? (YES/NO)
> no
 STARTING..
  DCB USED WITH FILE REBUILD  IS DCB=(RECFM=VB,LRECL=00088,BLKSIZE=23940)
 NUMBER OF SEGMENTS RETRIEVED=     576
  NEW FILE EMPLOYEE           ON 05/14/1999 AT 09.31.26
 NUMBER OF SEGMENTS INPUT=     576
 FILE HAS BEEN REBUILT

Information Builders