Contents Index Changing the encryption key for a database Adding synchronization to your application

UltraLite Static C++ User's Guide
  Adding Non Data Access Features to UltraLite Applications
    Configuring and managing database storage

Defragmenting UltraLite databases


The UltraLite store is designed to efficiently reuse free space, so explicit defragmentation is not required under normal circumstances. This section describes a technique to explicitly defragment UltraLite databases, for use by applications with extremely strict space requirements.

UltraLite provides a defragmentation step function, which defragments a small part of the database. To defragment the entire database at once, call the defragmentation step function in a loop until it returns ul_true. This can be an expensive operation, and SQLCODE must also be checked to detect errors (an error here usually indicates a file I/O error).

Explicit defragmentation occurs incrementally under application control during idle time. Each step is a small operation.

For more information, see ULStoreDefragFini function, ULStoreDefragInit function, and ULStoreDefragStep function.

To defragment an UltraLite database

  1. Obtain a p_ul_store_defrag_info information block. For example,

    p_ul_store_defrag_info     DefragInfo;
    //...
    db_init( &sqlca );
    DefragInfo = ULStoreDefragInit( &sqlca );
  2. During idle time, call UlStoreDefragStep to defragment a piece of the database. For example,

    ULStoreDefragStep( &sqlca, DefragInfo );
  3. When complete, dispose of the defragmentation block. For example,

    ULStoreDefragFini( &sqlca, DefragInfo );

Contents Index Changing the encryption key for a database Adding synchronization to your application