CREATE JOURNAL

From InterBase

Go Up to Statement and Function Reference (Language Reference Guide)


Creates a journal file and activates journaling.

CREATE JOURNAL [<journal-file-specification>] [LENGTH <number-of-pages>]
[CHECKPOINT LENGTH <number-of-pages> [PAGES]]
[CHECKPOINT INTERVAL <number-of-seconds> [SECONDS]]
[PAGE SIZE <number-of-bytes> [BYTES]]
[PAGE CACHE <number-of-buffers> [BUFFERS]]
[[NO] TIMESTAMP NAME]
[[NO] PREALLOCATE <number-of-pages> [PAGES]]
Argument Description

journal-file-specification

Specifies a quoted string containing the full path and base file name of the journal file. The base journal file name is used as a template for the actual journal file names as they are created. The default is the full database path and file name.

LENGTH

This clause specifies the number of pages that can be written to the journal file before rolling over to a new journal file. The maximum length is 2GB or 4000 pages.

CHECKPOINT LENGTH

This clause specifies the number of pages that can be written to the journal file before checkpoint occurs. The default is 500.

CHECKPOINT INTERVAL

Determines the number of seconds between database checkpoints. The checkpoint interval determines how long it will take to recover after a server crash. The default is 0.

Note: If both CHECKPOINT LENGTH and CHECKPOINT INTERVAL are specified, whichever event occurs first will initiate a database checkpoint.

PAGE SIZE

Determines the size of a journal page in bytes. A journal page size must be at least twice the size of a database page size. If a journal page size of less is specified, it will be rounded up to twice the database page size and a warning will be returned. The journal page size needs not be a power of 2. The default is twice the database size.

PAGE CACHE

Determines the number of journal pages that are cached to memory. This number must be large enough to provide buffers for worker threads to write to when the cache writer is writing other buffers. If the number is too small, the worker threads wait and performance suffers.The default is 100 buffers.

[NO] TIMESTAMP NAME

Determines whether or not to append the file creation timestamp to the base journal file name. The default is enabled.

If used, the base journal file name will be appended with a timestamp in the following format:

YYYY_MM_DDTHH_MM_SSZ.sequence_number.journal

[NO] PREALLOCATE

Determines journal file space requirements while simultaneously guaranteeing that the space is allocated in advance. The default is twice the database size.

Description: A journal consists of one or more journal files. A journal file records each database transaction as it occurs. To save changed journal pages in the database cache to the hard disk, you set up journaling checkpoints to occur automatically. A checkpoint specifies the time at which InterBase must save all the changed pages in the database cache to the database file.

The CREATE JOURNAL statement causes all subsequent write operations on a database to be done asynchronously. The journal file I/O is always synchronous and cannot be altered. All transaction changes are safely recorded on durable storage before the transaction is committed.

Journaling can be used with journal archiving to provide more complete disaster recovery.

Example: In the following example:

CREATE JOURNAL 'e:\database\test'
LENGTH 4000
CHECKPOINT LENGTH 10000
PAGE CACHE 2500;

The LENGTH parameter of 65000 will cause rollover to a new journal file every 1GB (65000 x 16KB). A CHECKPOINT LENGTH parameter of 10000 means the database checkpoint will occur every 160MB (10000 x 16KB). The 2500 journal buffer configuration will leave 2000 spare buffers for the worker threads to dump their journal changes. At the built-in PAGE CACHE default of 100, the worker threads can stall due to a high rate of journal buffer wait states.

See Also

Advance To: