The concept of starting and stopping a TimesTen in-memory database is different from that of a disk-based RDBMS. For TimesTen, a database is ready for use by an application after the database is loaded into memory.
Before you can connect to a TimesTen database, the TimesTen main daemon process needs to be started. Use the ttDaemonAdmin utility as shown below:
Database Loading and Unloading
The very first connection to a TimesTen database triggers the loading of the database to memory. The time it takes to load the database depends on the size of the database and the disk storage speed. The database resides in memory until the last connection disconnects, which automatically unloads the database from memory unless a RAM policy was set to keep the database loaded. The RAM policy setting is explained in the latter part of this section.
TimesTen databases are automatically persisted to disk storage using periodic checkpoints to keep snapshots of the database. Checkpoint files are used to load the database to memory. Before unloading a database, a final checkpoint is performed.
To gracefully shutdown a TimesTen database, disconnect all applications and agent processes from the database, and then execute the following command:
- The TimesTen main daemon process manages all databases under the same TimesTen installation. Be sure to disconnect all connections from all databases before running the above command.
- If the main daemon process is stopped while there are active agent processes, connections and transactions, the database is invalidated and will require a recovery procedure upon restart. Recovery of a failed database involves getting data from the checkpoint file and the transaction logs. Restarting a database that requires recovery takes longer time than restarting from a graceful shutdown.
RAM Policy Setting
TimesTen allows you to specify a RAM policy that determines when the database is loaded and unloaded from main memory. The policy options are:
- Load the database on first connection and unload on last disconnect. This is the default policy.
- Inuse with RamGrace:
- Keep the database in memory for a "grace period" after the last disconnect.
- Keep the database in memory at all times and automatically load the database upon restart of the TimesTen daemon process.
- Load and unload the database manually.
Choosing the RAM policy for your environment
Depending on your company's operational procedure and application characteristics, you should evaluate which RAM policy option is best for your production environment.
- This is the default policy setting and is convenient, particularly for development use. A disadvantage of this policy is that the first connection of the application needs to wait for the database to be loaded. If you have a relatively large database and the application does not always have a connection to the database, you may incur unnecessary wait time if the database needs to be loaded.
- Inuse with RamGrace:
- This policy is useful for applications with frequent periods of "idle" time when there is no connection to the database at all. Setting a "grace period" to keep the database in memory can avoid unnecessary load / unload operations.
- This policy keeps the database in memory whenever the server is up or rebooted, independent of the applications. This policy is useful if you have multiple applications sharing the database.
- This policy gives the database administrator more control over when the TimesTen database is loaded and unloaded. For enterprise companies where the TimesTen database is managed as part of their operational procedure to support the TimesTen applications, this policy is commonly used in system startup and shutdown procedures.