Hitachi

Hitachi Advanced Database Setup and Operation Guide


11.1.10 Reorganizing a single-chunk table

This section describes how to reorganize a single-chunk table.

Important

Do not execute an update SQL statement or a command that updates a table (such as the adbimport or adbmergechunk command) for a table that is being reorganized. If you do so, the changes made by the SQL statement or command might be lost after reorganization.

Organization of this subsection

(1) Reorganization procedure

The following shows the procedure for reorganizing a single-chunk table.

Procedure

  1. Make sure that no application programs and commands can access the reorganization-target table.

    Perform the following operations to prevent application programs and commands from accessing the reorganization-target table:

    • Execute the adbchgsrvmode command with the --offline option specified to change the HADB server operation mode to offline mode. Furthermore, if commands and jobs that update the table (such as the adbimport and adbmergechunk commands that are periodically executed) are executing on the HADB server machine, stop all of them.

    • Stop all application programs and commands that access the HADB server.

    We recommend that you perform both of the preceding operations.

  2. Export the data from the table.

    Export the data of the table by executing the adbexport command in which the reorganization-target table is specified for the -n option.

    For details about the adbexport command, see adbexport (Export Data) in the manual HADB Command Reference.

  3. Import the exported data in the creation mode.

    Execute the adbimport command with the -d option specified to import the data that was exported in step 2. If you specify the -d option, the data is imported in the creation mode. (In this mode, all the existing data in the table is deleted, and then the data exported in step 2 is imported.)

    For details about the adbimport command, see adbimport (Import Data) in the manual HADB Command Reference.

    Important

    When you execute the adbimport command, make sure that the value you specify for the import option (adb_import_rthd_num) satisfies the formula shown in (2) Estimating the value to be specified for the import option. If you specify a value that does not satisfy the formula, the data storage efficiency might degrade.

  4. Make sure that application programs and commands can access the reorganization-target table.

    Perform the following operation to enable application programs and commands to access the reorganization-target table:

    • If you changed the HADB server's operation mode to offline mode in step 1

      Execute the adbchgsrvmode command with the --normal option specified to change the HADB server operation mode to normal mode. If you stopped commands and jobs that were running on the HADB server machine, restart them.

    • If you stopped application programs and commands that access the HADB server in step 1

      Restart the application programs and commands that you stopped.

Note

For details about how to reorganize a multi-chunk table, see the following sections:

(2) Estimating the value to be specified for the import option

■ In a case where the single-chunk table is a row store table

When you execute the adbimport command, make sure that the value you specify for the import option (adb_import_rthd_num) satisfies the following formula. If you specify a value that does not satisfy the formula, the data storage efficiency might degrade.

Formula

value-specified-for-import-option-adb_import_rthd_num ≤
    ↑ number-of-segments-to-be-reorganized × data-storage-efficiency ↑ + 1
number-of-segments-to-be-reorganized

Substitute the number of segments used in the table.

Before you substitute the number of segments used in the table, execute the adbdbstatus command to output the table summary information. Then, check the output value for Used_segments (number of segments used by the table).

For details about the adbdbstatus command, see adbdbstatus (Analyze the Database Status) in the manual HADB Command Reference.

data-storage-efficiency

Substitute the value obtained in (2) If the single-chunk table is a row store table in 11.1.9 Checking whether a single-chunk table needs to be reorganized.

■ In a case where the single-chunk table is a column store table

When you execute the adbimport command, make sure that the value you specify for the import option (adb_import_rthd_num) satisfies the following formula. If you specify a value that does not satisfy the formula, the data storage efficiency might degrade.

Formula

value-specified-for-import-option-adb_import_rthd_num ≤
    ↑ number-of-segments-to-be-reorganized × number-of-rows-to-be-reorganized
       ÷ number-of-rows-stored-in-column-data-segment ↑ + 1
number-of-segments-to-be-reorganized

Substitute the number of column-data segments used in the table.

To check the number of column-data segments used in the table, execute the adbdbstatus command with the -d used option specified to output usage information for DB areas, tables, and indexes. Then, check the information output as Used_segments (number of used segments) on each row whose Segment_type (segment type) is Column_data (column-data segment).

number-of-rows-to-be-reorganized

Substitute the number of rows to be reorganized. You can check the number of rows in the table by executing the following SELECT statement:

SELECT COUNT(*) FROM "table-name"
number-of-rows-stored-in-column-data-segment

Substitute the number of rows that were imported into the reorganization-target table by using the adbimport command. Alternatively, substitute the number of rows that were converted from row store format to column store format by using the updated-row columnizing facility.

Execute the adbdbstatus command to obtain information about the need for reorganization. The value of Column_data_num is the number of rows stored in the column-data segment.