Reducing Database Size for TimesTen

Once a TimesTen database has been defined with a particular size for the permanent region (indicated by the PermSize DSN attribute), it cannot be reduced to a smaller size, even if tables or rows are deleted.

To reduce the allocated size of the permanent region of a TimesTen database, run the ttMigrate utility to save a copy of the database and then re-create the database with a smaller permanent region size and restore the data.

Perform these steps to reduce the permanent region size of a TimesTen database:

  1. Disconnect applications from the database with the ttAdmin -disconnect command. See Disconnecting from a Database in TimesTen in this book and ttAdmin in the Oracle TimesTen In-Memory Database Reference.
  2. Use the ttMigrate -c option to create a data file for the database.
    ttMigrate -c database1 /tmp/database1
  3. Unload the TimesTen database from memory. See Unloading a Database from Memory for TimesTen.
  4. Create a new DSN definition for the new copy of the database with a smaller PermSize value. To modify the original DSN rather than create a new one, you must destroy the original TimesTen database using the ttDestroy utility before restoring from the backup.
  5. Recreate the TimesTen database by using ttIsql with AutoCreate=1.
    ttIsql -connstr "dsn=database1;AutoCreate=1" -e "quit"

    The database is empty at this point.

  6. Restore the backup by using the ttMigrate -r and -relaxedUpgrade options.
    ttMigrate -r -relaxedUpgrade database1 /tmp/database1

Note:

  • The permanent region size of a TimesTen database cannot be reduced below the size that is required by the data currently stored in the database. This value can be determined by querying the perm_in_use_size column of the v$monitor system view.

  • You can also use this procedure to compact the TimesTen database in order to reduce fragmentation caused by partially full table pages or fragmentation of the heap buffers that store index nodes and out-of-line values.