Disk Tablespace
Disk Tablespace#
A disk tablespace is a tablespace in which all of the data therein are stored on disk. This section discusses the structure of disk tablespaces, which is based on disk data pages, and how row data are input into disk pages.
Data Page Structure#
In Altibase, the smallest unit of database storage space management is the page. The size of a page is 8KB. Multiple page sizes are not supported.
A data page is one of several kinds of pages, and stores row data. Row data are stored in free space, starting from the end of the page. If there is not enough free space, it is advisable to create larger regions of free space using compaction to turn fragmented space into contiguous space.

The data page consists of six different areas, as shown in [Figure 6-8].
-
Physical Header
This area contains information common to all pages, regardless of the type of page.
-
TTL (Touched Transaction Layer)
This area contains MVCC (Multi-Version Concurrency Control) related information.
-
Slot Directory
This area contains information about so-called "row offset", that is, the location within the page at which the Row Data area is saved.
-
Free Space
This area is available space that is used for saving the results of operations such as insert and update operations.
-
Row Data
-
Page Footer
This area is located at the end of the page and contains information that is used for checking page integrity.
Managing Space in Disk Tablespace#
Disk tablespace can be manually managed using the PCTFREE and PCTUSED parameters.
The PCTFREE and PCTUSED parameters can be used to control the use of free space when performing input or update operation on raw data.
These two parameters are set using the PCTFREE and PCTUSED properties in the altibase.properties file. They can also be explicitly specified when a table is created using the CREATE TABLE statement or changed using the ALTER TABLE statement.
PCTFREE#
PCTFREE is the minimum amount of free space, expressed as a percentage, that is reserved for updating rows that have already been stored in a page.
For example, if PCTFREE is set to 20, data can be inserted into the page until it is 80% full, and the remaining 20% of the page will be set aside for use in updating existing rows.

PCTUSED#
PCTUSED is the threshold percentage below which the amount of used space in a page must decrease in order for the page to change from the state in which only update operations are possible to the state in which records can be inserted.
If the amount of free space falls below the limit specified in PCTFREE, it becomes impossible to insert new records into the page, and free space in the page can only be used to update existing rows. This state persists until the percentage of used space falls below the threshold specified by PCTUSED.

Row Structure#
Rows can be divided into one or more pieces. If it is possible to store an entire row in a page, it is saved as one row piece. However, if it is not possible to store the row in a single page, the row is divided into several pieces and then saved.
These row pieces are "chained", that is, they are associated with each other via a common ROWID value.

A row piece consists of a row header and a row body.
A row header contains header information of 18 bytes size. In the case of a chained row piece, the row header contains 6 more bytes for storing the value of ROWID.
In the row body, pairs comprising the length of a column and the value stored in the column are stored sequentially. If the value stored in the column is less than 250 bytes, only 1 byte is necessary for storing the column length, whereas 3 bytes are used to store the column length if the value stored in the column exceeds 250 bytes.
In order to conserve space, if the value of the column is NULL, only the length of the column, which is 0, is saved. No column value is saved. Additionally, for columns that contain NULL values and are located at the end of the row, neither the column value nor the length is saved.
Columns are saved in the order in which they are specified in the CREATE TABLE statement. Therefore, when executing the CREATE TABLE statement, locating columns that are expected to contain NULL values at the end of the row frequently is good practice, because it can reduce the amount of space required to store rows.
Row Chaining and Migration#
When row data are too large to be saved in a single page, row chaining and row migration will occur.
Row chaining occurs when data that are being inserted are so large that the row containing them cannot fit in a single page. When row chaining occurs, long rows are divided into pieces and saved in multiple pages. These pieces are associated with one another by their common ROWID value.
Row migration occurs when a row that was saved in a single page is increased in size by an update operation and thus can no longer fit in a single page. In this case, the entire row is migrated to new pages. The original row becomes a pointer that indicates the new location where the row is saved. However, when a row is migrated, the ROWIDs of its pieces do not change.
When row chaining or migration occurs, one more page must be read during DML processing, resulting in performance deflation due to disk I/O.