Database File Size

From InterBase

Go Up to Database Files

InterBase database file size is the product of the number of database pages times the page size. The minimum page size is 1 KB, the default page size is 4KB, and the maximum page size is 16KB. Each page can store records only from a single table. You set the database page size when you create a database by using the PAGE SIZE clause of the CREATE DATABASE statement, or its equivalent in IBConsole. You can change the page size when you restore a database using gbak or IBConsole.

InterBase supports 64-bit file IO, so the size of a database file is effectively limited only by the operating system.

Using gbak is the only way to reduce the size of the primary database file. When you restore a database, you can specify multiple files without reference to the original file sizes.

Dynamic File Sizing

InterBase dynamically expands the last file in a database as needed. This applies to single-file databases as well as to the last file of multifile databases. Specifying a LENGTH for the last or only file in a database has no effect.

Database File Preallocations

The InterBase SQL statement CREATE DATABASE includes a preallocation clause to specify extra database space for the new database. The space is actually allocated when the user detaches from the connection that was established by the CREATE DATABASE statement. The database preallocation feature supports secondary database files in that the preallocation will be spread across all secondary files in accordance with their file size specifications.

To specify preallocation, use the following syntax:


... [[NO] PREALLOCATE [=] int [PAGES]]

By default, creating a database does not preallocate additional database pages, so it is as if NO PREALLOCATE had been specified. IB provides this syntax so that a DDL script can explicitly state and document that preallocation has not been specified. Database preallocation is always specified in units of database pages to be consistent with other related features (i.e., length of secondary database files or shadow sets).

If a preallocation exceeds available disk space, the IB thread making the write request when the device fills will timeout after 1 minute of waiting for the I/O to complete. It makes 4 additional I/O attempts, waiting 1 minute each time, to complete the write (results written to the InterBase log). If space is not freed to allow the preallocation operation to continue, the space requested will not be allocated.

isql -extract PREALLOCATE

The CREATE DATABASE command now includes the isql -extract PREALLOCATE clause to the formatted CREATE DATABASE statement if there is a non-zero preallocation value for the database. The isql extract operation can be invoked with the -a|-x options.

GSTAT (Database File Size)|GSTAT

GSTAT displays the database preallocation information, which is stored on the database header page. Following is a sample from a GSTAT -H command:


variable header data:
Preallocate pages: 5000
Sweep interval: 25000

API DPB Parameter

At the InterBase API-level, there is a DPB parameter, isc_dpb_preallocate, that takes a 4-byte integer to specify database preallocation. It is only recognized and processed by isc_create_database(). isc_attach_database() silently ignores isc_dpb_preallocate. You can use the isc_info_db_preallocate database info parameter to request database preallocate information stored on the database header page.

With the InterBase service API, actions isc_action_svc_backup (isc_action_svc_restore) take new parameters, isc_spb_bkp_preallocate (isc_spb_res_preallocate), respectively. Both parameters take a 4-byte argument to specify the database preallocation in units of database pages. The service parameters have the same numeric value but two symbolic constants are provided for source code clarity to show the proper intent.

See “Working with Databases” in the API Guide for more information about DPB parameters.

See Also

Advance To: