Overview of Sweeping

From InterBase

Go Up to Sweep Interval and Automated Housekeeping


InterBase uses a multigenerational architecture. This means that multiple versions of data records are stored directly on the data pages. When a record is updated or deleted, InterBase keeps a copy of the old state of the record and creates a new version. This can increase the size of a database.

Garbage Collection

To limit the growth of the database, InterBase performs garbage collection by sweeping the database. This process frees up space allocated to outdated record versions. Whenever a transaction accesses a record, outdated versions of that record are collected. Records that were rolled back are not collected. To guarantee that all outdated records are collected, including those that were rolled back, InterBase periodically sweeps the database.

Automatic Housekeeping

If a transaction is left in an active (unresolved) state, this is an “interesting” transaction. In a given transaction inventory of a database, the first transaction with a state other than committed is known as the Oldest Interesting Transaction (OIT). Automatic housekeeping occurs when the difference between the OIT and the oldest active transaction (OAT) is greater than the sweep interval. By default, this sweep interval is 20,000, but it is configurable (see Setting the Sweep Interval).

Note:
It is a subtle but important distinction that the automatic sweep does not necessarily occur every 20,000 transactions. It is only when the difference between the OIT and OAT reaches the threshold. If every transaction to the database is committed promptly, then this difference it is not likely to be great enough to trigger the automatic sweep.

The InterBase server process initiates a special thread to perform this sweep asynchronously, so that the client process can continue functioning, unaffected by the amount of work done by the sweep.

Tip:
Sweeping a database is not the only way to perform systematic garbage collection. Backing up a database achieves the same result, because the InterBase server must read every record, an action that forces garbage collection throughout the database. As a result, regularly backing up a database can reduce the need to sweep. This enables you to maintain better application performance. For more information about the advantages of backing up and restoring, see About InterBase backup and restore options.

Configuring Sweeping

You are able to control several aspects of database sweeping. You can:

  • Change the automatic sweep interval.
  • Disable automatic sweeping.
  • Sweep a database immediately.

The first two functions are performed in the Database Properties dialog. The last is performed with a sweep menu command and is explained in Performing an Immediate Database Sweep.

Advance To: