Table X (File architecture)

From m204wiki
Revision as of 22:15, 29 January 2014 by ELowell (talk | contribs)
Jump to navigation Jump to search

Stores all extensions to a Model 204 record in a separate table from the the base records (so that Table B contains only the base records).

Table X is enabled when you reorganize or CREATE a file with XSIZE greater than 0.

Table X is available as of Model 204 version 7.1.

Summary

The Table B of a Model 204 file has a maximum number of 16.7 million record numbers (IRNs, for Internal Record Numbers). By default (XSIZE = 0), these "slots" are used for both base records and extension records.

By implementing Table X (XSIZE > 0) all defined IRNs (up to 16.7 million) in Table B are available for use by base records only, allowing the storage of the maximum possible number of records in a file regardless of the number of extensions.

Table X can be significantly larger than the 16.7 million limit of Table B: the product of XSIZE * XRECPPG may be up to 512 million extension slots.

When the defined capacity of Table B or Table X is exceeded, the file is marked full or the updating transaction is backed out.

Using Table X

While similar in concept to Table B, the actual "extension record number" in Table X is far more straightforward:

  • Because the number of slots in Table X is so large, and there is effectively no impact in wasting slots (until you approach that limit) XRECPPG can usually be set relatively high.
  • Similarly, depending on how dynamic record growth is, you might want to set XRESERVE higher than you would normally consider setting BRESERVE. This will enable records to grow without lengthening the extension chain.
  • Table X slots are always reusable. There is no special setting (equivalent to FILEORG X'04') necessary to enable the use of the reuse queue.

RECRDOPT parameter

Table X can be implemented in one of two ways depending on the setting of the RECRDOPT parameter.

RECRDOPT is set only at file creation; you cannot reset it later. To use RECRDOPT with files created prior to Model 204 version 7.1, you must reorganize the files under Model 204 version 7.1 or later.

The default setting of RECRDOPT (X'00')

If the default setting of the RECRDOPT parameter is used, while all extensions are stored in Table X, the record allocation in Table B is identical to what it is without Table X enabled.

BRECPPG remains the maximum number of records that can occur on a page, so IRNs might still be wasted (never assigned to a record) as data fills up a page.

Setting RECRDOPT parameter to X'01'

This setting changes the base record allocation to ensure that all defined IRNs are available for use.

For all X'01' RECRDOPT files, a base record size limit (the read only parameter BRLIMSZ) is calculated:

  • For an entry order file:

    BRLIMSZ = (6140 / BRECPPG) - 2

  • For an unordered file:

    BRLIMSZ = (6136 / BRECPPG) – 2

If RECRDOPT=1, the maximum allowed value of BRECPPG is 1022 for ordered files and 1023 for unordered files.

When a new record is stored, rather than using any and all space available on a page, only up to BRLIMSZ bytes will be stored in Table B. This ensures that the full BSIZE * BRECPPG number of IRNs can actually be stored in the file.

BRLIMSZ must be large enough to hold all preallocated fields.

(Note that the BRESERVE parameter is ignored (treated as a 0) with X'01' RECRDOPT files).

Advantages of Using Table X

Scalability

The obvious advantage of implementing Table X relates to the ability to store the full 16.7 million base records in a Model 204 file.

Indexing performance

Even if a file has significantly fewer records than the limit, you should consider the performance of your indices in deciding whether to utilize Table X, notably where you expect to have fields with non unique values.

When Table X is enabled and RECRDOPT = X'01', the fact there are no wasted slots means that the bitmaps containing the bitmap and list pages (and, of course, the existence bitmap) are as compressed as possible.

Avoidance of "sick record" snaps

When large sets of unlocked records (either through the use of Find Without Locks (FDWOL) or by referencing records on a Model 204 list) are processed, it is very possible that the records will have had their contents changed or even been deleted by the time the record is read. There are three problems that might be encountered when this happens:

  • The record should no longer be selected, its contents no longer matching the selection criteria
  • The record has been deleted (and so 'Nonexistent record' messages are produced)
  • The record now (due to delete and update processing) contains an extension record

The last of these problems causes a "sick record" snap.

While Rocket Software encourages the use of coding techniques to prevent all of these issues, File Managers can protect themselves from the snaps (at least) by enabling Table X in files where such processing is expected.

Parameters related to the use of Table X

BRLIMSZ Calculated maximum size of base records
RECRDOPT Controls the method by which base records are stored
XAUTOINC Number of pages for Table X auto increase
XHIGHPG Table X highest active page
XQLEN The number of Table X pages in the reuse queue
XRECPPG The maximum number of extension slots on a Table X page
XRESERVE Table X reserve space per page
XREUSE Free space required to reuse a table X page
XREUSED The number of extension slots reused in table X
XSIZE The number of pages in Table X

The use of these parameters is discussed in Sizing Tables B and X.