Table E and non-FILEORG X'100' files (File architecture)

From m204wiki
Revision as of 19:00, 1 September 2016 by JAL (talk | contribs) (add link)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Holds Large Object data (BLOBs and CLOBs)

Storage and manipulation of Large Objects (LOBs) differs greatly depending on whether FILEORG X'100' is set for the file. This page discusses working with files where FILEORG X'100' is not set; for a parallel discussion of working with LOBs in files where FILEORG X'100' is set, see Table E and FILEORG X'100' files (File architecture). For a summary of the differences between working with LOB data in files where FILEORG X'100' is set and files where it is not, see Table E (File architecture).

Model 204 stores Large Objects as consecutive chunks of Table E pages. When Large Objects are created and deleted frequently, gaps can occur between objects that may not be reused due to their small size.

When the FILEORG X'100' bit is not set on a file, you enable Large Object storage by:

  1. Reorganizing/creating a file with ESIZE parameter value greater than 0.
  2. Defining one or more fields with an attribute of CLOB or BLOB (the file must have a non-zero ESIZE value for the latter to occur).

Table E storage of LOB data is available as of Model 204 V7.1.

Summary

Regarding the storage and manipulation of Large Objects (LOBs):

  • Table E storage of files that are not defined with the FILEORG X'100' bit is a reasonable choice for static stores of Large Objects (such as scanned forms).
  • If you expect that there will be large numbers of adds, changes, and deletes, however, strongly consider using FILEORG X'100' files.

Bitmaps to track space availability

In Table E, in addition to the pages used to store the Large Object Data, there are bitmap pages which track the page use. For every 49152 pages of Table E defined, there will be one bitmap page.

The boundaries of these sets of records are a consideration in the execution of the COMPACTE command, because the compactor processes one of these sets at a time, and LOBs stored on pages that span a bitmap boundary do not participate in the compaction.

Storing Large Objects

When a field is defined as a large object (LOB) (using the attributes BLOB or CLOB), a pointer is stored in the record (in Tables B or X) and the LOB is stored in Table E.

Pointer in the record

When you store a Large Object value in Table E, a Large Object descriptor is stored in Table B (or Table X depending on where the field is being added). The descriptor contains the length, reserve, and a pointer to the Large Object data in the Table E page and is 27 bytes long (or 30 bytes long if the field is not preallocated).

Large Object header

Every large object stored in Table E starts with a Large Object header, which is used to make the Table E compaction work better. The Large Object header contains a field for the Table B record number that points to the large object—thus the field is a backward pointer to the Table B record.

Implementing a Large Object header requires file reorganization if the file was created earlier than V7.1. Only V7.1 or later files are eligible for COMPACTE processing. No application changes are required.

Note: Files created in V7.1 with Table E size greater than zero are not backward compatible and cannot be opened in earlier releases.

The large object header has the following 4-byte entries:

  • Table B record number
  • Large object length in pages, including reserved pages
  • Field attribute

    The field attribute facilitates the Table B record search to find a field with the object descriptor.

  • Five reserved fullwords

So, the first 6132 bytes of a Large Object are on the first Table E page, while later pages will fit 6144 bytes. If you plan on storing a large number of relatively small LOBs, take this size differential into account when sizing Table E.

Table E space utilization

Each instance of a Large Object field occupies an integral number of Table E pages, where each page can hold up to 6144 bytes of data (the first page only 6132 due to the header).

  • A Large Object field with a null value (or 0 bytes of data) occupies no Table E pages.
  • Large Object field data from 1 to 6132 bytes occupies one Table E page. If the data is from 1 to 6131 bytes, the page is not completely filled, so the remainder of the page is unused.
  • Large Object data of 6133 bytes requires two Table E pages, and LOB data of 12277 bytes will take three pages (6132 + 6144 + 1).

Storing a Large Object

The pages used to store a Large Object value are always contiguous in Table E. If you specify the RESERVE option when the data is stored (and you must if you wish the object to expand in size after its initial store), then enough contiguous pages are allocated to hold the full RESERVE length, even if the actual size of the data initially stored is less than that.

If possible, when space to store Large Object data is required from Table E, then the space is allocated from the pages past EHIGHPG—even if there are free pages in Table E before the EHIGHPG point. In other words, data in Table E is initially stored in entry order. Eventually, when there is insufficient space left at the end of Table E, then space is allocated from the unused pages in Table E. Unused pages are a result of deleting Large Object data.

Generally speaking, the cost of finding free space in Table E is very low during the initial phase, when EHIGHPG is still increasing, but more expensive later, particularly when Table E free pages are fragmented: for example, if the Large Object data stored in the file show a wide variation in size.

If the Large Object data stored in your database are volatile because of a high number of deletions and additions, Rocket Software recommends that you use FILEORG X'100' files.

Parameters and commands related to the use of Table E

Name Description
COMPACTE command Defragment the contents of Table E.
EHIGHPG parameter The highest active Table E page. (The first page in Table E is page zero.)
EPGSUSED parameter The number of Table E pages currently in use.
ESIZE parameter The number of pages in Table E.
FILEORG parameter The file organization.