Database write mode

<< Database validation and recovery | Firebird Database Housekeeping Utility | Version number >>

Database write mode

Many operating systems employ a disc cache mechanism. This uses an area of memory (which may be part of your server's overall RAM or may be built into the disc hardware) to buffer writes to the hardware. This improves the performance of applications that are write intensive but means that the user is never certain when their data has actually been written to the physical disc.

With a database application, it is highly desirable to have the data secured as soon as possible. Using Firebird, it is possible to specify whether the data should be physically written to disc on a COMMIT or simply left to the operating system to write the data when it gets around to it.

To give the DBA or database owner full control of when data is written, the gfix -w[rite] command can be used. The command takes two parameters:

 gfix -write MODE database_name

The MODE parameter specifies whether data would be written immediately or later, and is one of:

  • sync - data is written synchronously. This means that data is flushed to disc on COMMIT. This is safest for your data.
  • async - data is written asynchronously. The operating system controls when the data is actually written to disc.

If your system is highly robust, and protected by a reliable UPS (uninterruptable Power Supply) then it is possible to run asynchronously but for most systems, synchronous running is safest this will help prevent corruption in the event of a power outage or other uncontrolled shutdown of the server and/or database.

Note: Firebird defaults to synchronous mode (forced writes enabled) on Linux, Windows NT, XP, 2000, 2003 and Vista.

This command has no effect on Windows 95, 98 and ME.

Warning: Cache flushing on Windows servers (up to but not including Vista - which has not been confirmed yet) is unreliable. If you set the database to async mode (forced writes disabled) then it is possible that the cache will never be flushed and data could be lost if the server is never shutdown tidily.

Warning: If your database was originally created with InterBase 6 or an early beta version of Firebird then the database will be running in asynchronous mode - which is not ideal.

back to top of page
<< Database validation and recovery | Firebird Database Housekeeping Utility | Version number >>