In order to adapt the stored data to the modified schema or modified storage structure, BALTER requires additional free memory space
in order to create new tables, hash areas or DBTTs
in order to re-store records, tables, hash areas or DBTTs.
If the free memory space in the realms is not large enough to do this, BALTER automatically extends the realms concerned, provided this is possible (requirement: secondary allocation for memory space > 0). For details, please see "Database Operation" manual, Automatic realm extension by means of utility routines.
If automatic realm extension is not possible (secondary allocation for memory space = 0 or no more disk storage is available), BALTER aborts restructuring! As a result your database is inconsistent and you must revert to the status before restructuring began and start again from the beginning.
Realms without automatic realm extension
When one or more realms with a secondary allocation = 0 are configured, e.g. because you do not want automatic realm extension, you must ensure that the available space is sufficient before you begin restructuring. For this purpose you must use BSTATUS to display how much memory space is still free in the various realms of your database and estimate whether the free space is sufficient for the planned restructuring.
This should be done as early as possible, since BREORG can no longer enlarge the realms of the database once BCHANGE has processed the database for restructuring purposes.You can also make use of the analysis report for this purpose (see section "Description of the analysis report (REPORT phase)").
BALTER selects the processing sequence in such a way that it first deletes those elements from the database which are no longer contained in the new schema. The space released can then later be used in the course of other activities, such as the creation of new tables, the creation of new hash areas, the re-storing of records etc. In the same way the space released after re-storage of a record type can be used again. Unfavorable configurations may however lead to a situation in which space which is free at the end of a realm is allocated first of all, leaving gaps at the beginning of the realm. If this is the case, it is possible, by means of the BREORG utility routine, to relocate hash areas and tables to the free pages at the beginning of the realm:
hash areas with REORGANIZE-CALC
tables with REORGANIZE-SET.
You can then reduce the realm by deleting the pages released at the end of the realm.
The overviews on the following pages are intended to help you estimate the size of the free memory space which must be available for restructuring purposes in the realms of the database. If insufficient free space is found in a realm, it must be extended using BREORG before BCHANGE is started for purposes of preparing restructuring.
DBTT
BALTER lists in an analysis listing the free memory space it needs to restore a DBTT or to create a new DBTT.
The new size of a DBTT can also be determined using the formulas specified in the table.
Modification in | R e a s o n | Memory requirement | ||
Formula | SSL clause | Standard | ||
Creating a new | new record type defined | DBTT clause | 1 page | |
Re-storing | Number of DBTT columns changed (only in owner record) by
DBTT relocated by
|
|
|
Table 29: Memory requirement for DBTT modifications
Hash areas
The number of pages which BALTER needs to create a hash area is given in the analysis listing.
The size of the hash areas can also be determined with the aid of formulas.A hash area always occupies contiguous pages of a realm.
Modification in | R e a s o n | Memory requirement | ||
Formula | SSL clause | Standard | ||
Creating a direct or |
| or | POPULATION | 1 page |
Creating an indirect |
| DBTT clause | 1 page | |
Converting a direct | A record type defined with LOCATION CALC
| POPULATION | 1 page | |
Converting an indirect | In a record type defined with LOCATION CALC
|
Table 30: Memory requirement for modifications affecting hash areas
Tables
Relocating tables
BALTER can relocate only single-level tables in their entirety. If it relocates tables to another realm, the space required in that realm is equal to the space originally occupied by the table.
Creating new tables:
SYSTEM set or TYPE IS DATABASE-KEY-LIST:
each set occurrence table occupies at least one page.Non-singular set and not TYPE IS DATABASE-KEY-LIST:
each set occurrence table takes up only as much space as it needs.
BALTER stores tables for the same set using a space-saving strategy such that there may be a number of tables in the same page, if the tables are stored DETACHED.
Table | Change in Schema DDL | Change in DB | Memory requirement | |
Create new | Relocate | |||
Indexed | new SEARCH key defined | X | - | min. 1 page max. refer to formula 5 |
Key item changed | X | - | ||
Table type changed | X | - | ||
Definition of a SEARCH key | X | - | ||
SEARCH key table relocated | X | - | ||
Indexed | Table type changed | X | - | min. 1 page per set occurrence table with SYSTEM set: |
New SEARCH key defined | X | - | with SYSTEM set: min. 1 page with non-singular set: minimum not specifiable.
| |
Key item changed | X | - | ||
Table type changed | X | - | ||
Definition of a SEARCH key | X | - | ||
SEARCH key table relocated | X | - | ||
Indexed | MODE clause changed to | X | - | |
ASC/DSC key changed | X | - | ||
Pointer array relocated | X | - | ||
New set defined with | X | - | ||
Indexed | New set defined with MODE | X | - | |
Definition of a set | X | - | ||
ASC/DESC key changed | X | - | ||
Table relocated to | X | - | ||
Non-indexed | Pointer array relocated | - | X | Original size |
Indexed | MODE clause changed to | X | - | with SYSTEM set: with non-singular set: max. size of a single set occurrence table: |
ASC/DESC key changed | X | - | ||
New set defined with MODE | X | - |
Table 32: Memory requirements for table changes
The following changes are allowed only when there are no member records:
creation of a single-level list or a single-level pointer array (caused e.g. by MODE definition, changed ORDER clause)
relocation of a single-level list in the same realm (e.g. by record lengthening)
relocation of a list to another realm
Record reallocation
When records are reallocated, a distinction is made by BALTER between a partial and a complete reallocation:
A complete reallocation
occurs when the new schema prescribes a special form of storage. This is the case with
LOCATION MODE IS CALC for direct hash areas and record types stored in a list.A complete reallocation is carried out by BALTER when:
you use a hash routine other than the standard routine in the new schema
you change the CALC key for a direct hash area in the new schema
you do not specify the reason for indirect storage in the new schema
you introduce LOCATION MODE IS CALC in the new schema
you change the ASC/DESC key of a list in the new schema
you redefine MODE IS LIST in the new schema.
In the case of a complete reallocation, BALTER relocates all records to new pages and releases the old pages. This means, however, that during the BALTER run double the storage space required for storing the records must be available.
If a record type with a special form of storage is lengthened, a complete reallocation is automatically initiated, even if there is no change in the form of storage itself.
A partial reallocation
occurs when either the user or system part of the records is lengthened, thus making more pages necessary for storage purposes.
In the case of a partial reallocation, as many records as possible are kept in their original pages, and the rest are relocated by BALTER to new pages.
Shortening records
If a record type with a special form of storage is shortened, a complete reallocation is automatically initiated as for the lengthening of records, even if there is no change in the form of storage.
If a record type without a special form of storage is shortened, BALTER pushes all the records within a page together. This releases space within the individual pages. BALTER does not relocate the records to other pages, however, so no whole pages are released.
BALTER does not indicate the amount of space required to relocate records in the analysis listing. It is, however, possible to estimate the required storage space with the help of table 33 of and the calculation formulas which follow.
Modification | R e a s o n | Memory requirement | |||
Formula | SSL clause | Standard | |||
Complete | Direct | LOCATION MODE changed to CALC | POPULATION | 1 page | |
Hash routine/CALC key | |||||
Hash area converted | |||||
Indexed | New set defined with MODE IS LIST | with SYSTEM set: min. 1 page with non-singular set: minimum not specifiable. max. size of a single set occurrence table: | |||
MODE clause changed to LIST | |||||
ASC/DESC key changed | |||||
| User part lengthened | BALTER enters as many records as possible in the previous pages and
| |||
System | Record type compressed | ||||
Owner linked to its table | |||||
Member linked to its owner | |||||
MODE IS CHAIN introduced | |||||
Owner/member record type: | |||||
LINKED TO PRIOR or to MODE IS CHAIN | |||||
Member record type: new set added | |||||
Record | User part shortened | BALTER pushes together the records in a page (except for record type with special Additional free memory space is not required (except for record type with | |||
System | Record type decompressed | ||||
Linkage of owner to its table cancelled | |||||
Linkage of member to its owner cancelled | |||||
Sets defined with MODE IS CHAIN deleted | |||||
LINKED TO PRIOR and | |||||
MODE clause changed from | |||||
Set in which record type was |
Table 33: Memory requirements for record reallocation
Calculation formulas
The calculation formulas indicated below can be used to calculate the following values:
DBTT size for a new DBTT
DBTT size for a re-stored DBTT
size of a direct hash area
size of an indirect hash area
size of a multi-level SEARCH key table on record type level
Calculating the DBTT size for a new DBTT:
2044 / LENGTH = entries-per-page
1)
(for 2048-byte page length)
3980 / LENGTH = entries-per-page
1)
(for 4000-byte page length)
8076 / LENGTH = entries-per-page
1)
(for 8096-byte page length)
integer / entries-per-page = number-of-pages
2)
1) The result must be rounded down to an integer
2) The result must be rounded up to an integer
number-of-pages
Number of DBTT pages
entries-per-page
Number of DBTT entries per page
integer
Number of planned records as in DBTT clause
LENGTH
Length of a DBTT entry; is contained in the BGSIA report under the heading: ’DBTT-INFORMATION’ (see the "Recovery, Information and Reorganization" manual)
Calculating the DBTT size for a re-stored DBTT:
2044 / LENGTH-new = entries-per-page-new
1)
(for 2048-byte page length)
3980 / LENGTH-new = entries-per-page-new
1)
(for 4000-byte page length)
8076 / LENGTH-new = entries-per-page-new
1)
(for 8096-byte page length)
prev.-total-no.-of-entries / entries-per-page-new = number-of-pages
2)
1) The result must be rounded down to an integer
2) The result must be rounded up to an integer
number-of-pages
Number of DBTT pages
prev.-total-no.-of-entries
Number of entries in the original DBTT; this value can be determined using BSTATUS
entries-per-page-new
Number of DBTT entries per page in the new DBTT
LENGTH-new
Length of an entry in the new DBTT
LENGTH-new
= 4 x (n
+ 1)n
Number of all the tables of the sets in which the record type is the owner record typeCalculating the size of a direct hash area:
No allowance is made for the number of overflow pages which BALTER must also create.
(page-length - 30) / (record-length + calc-key-length + 15) = entries-per-
page1)
(integer - 1) / entries-per-page + 1 = number-of-pages
2)
1 The result must be rounded up to an integer
2 The result must be rounded up to the next-higher prime number if no prime number is obtainedpage-length
Page length of the database (2048/4000/8096 bytes)
number-of-pages
Number of pages in the hash area
calc-key-length
Length of CALC key; is given in the BGSIA report under the heading ’CALC-INFORMATION’ in the LENGTH column (see the "Recovery, Information and Reorganization" manual).
integer
Number of records to be stored according to the POPULATION clause (record type level).
record-length
Length of record type including SCD; is given in the BGSIA report under the heading ’RECORD-INFORMATION’ in the LENGTH column (see the "Recovery, Information and Reorganization" manual).
entries-per-page
Number of entries (records or CALC index entries) per page.
Calculating the size of an indirect hash area:
No allowance is made for the number of overflow pages which BALTER must also create.
(page-length - 30) / (calc-key-length + 7) = entries-per-page
1)
(integer - 1 ) / entries-per-page = number-of-pages
2)
1) The result must be rounded up to an integer
2) The result must be rounded up to the next-higher prime number if no prime number is obtainedinteger
Number of records to be storedaccording to POPULATION clause (primary key)
according to DBTT clause (secondary key).
For other meanings, see the previous formula.
Calculating the size of a multi-level SEARCH key table (record type level)
This formula is based on slightly simplified assumptions and therefore produces an estimate, not the exact numerical value.
For a 2048-byte page length:if an occupancy level was specified:
no.-of-search-keys 2002 - a
-------------------------------------- * ---------- = no.-of-pages
max(1, (2002 / a * occ. level / 100))
1)
2002 - 2a1) The result of the first division and the result of the first multiplication must each be rounded down to an integer
If no occupancy level was specified:
no.-of-search-keys 2002 - a
------------------ * ---------- = no.-of-pages
(2002 / a ) -1)
2)
2002 - 2a2) The result of the division must be rounded down to an integer
where:
a = search-key-l + 7
For a 4000-byte page length:
if an occupancy level was specified:
no.-of-search-keys 3950 - b
-------------------------------------- * ---------- = no.-of-pages
max(1, (3950 / b * occ. level / 100))
1)
3950 - 2b1) The result of the first division and the result of the first multiplication must each be rounded down to an integer
If no occupancy level was specified:
no.-of-search-keys 3950 - b
------------------ * ---------- = no.-of-pages
(3950 / b ) -1) 2) 3950 - 2b2) The result of the division must be rounded down to an integer
where:
b = search-key-l + 10
For an 8096-byte page length:if an occupancy level was specified:
no.-of-search-keys 8046 - b
-------------------------------------- * ---------- = no.-of-pages
max(1, (8046 / b * occ. level / 100))
1)
8046 - 2b1) The result of the first division and the result of the first multiplication must each be rounded down to an integer
If no occupancy level was specified:
no.-of-search-keys 8046 - b
------------------ * ---------- = no.-of-pages
(8046 / b ) -1)
2)
8046 - 2b2) The result of the division must be rounded down to an integer
where:
b = search-key-l + 10
no.-of-pages
Number of pages required for the whole set occurrence table
no.-of-search-keys
Number of keys in the table
occ. level
Percentage occupancy level (see the FILLING clause, "BALTER statements")
search-key-l(ength)
Length of the SEARCH key; is given in the BGSIA report under the heading ’KEY-INFORMATION’ (NO CALC SEARCH KEY’S)’ in the LENGTH column (see the "Recovery, Information and Reorganization" manual).