Defragmenting TimesTen Databases
A secondary table partition is created after a table has been altered with the ALTER TABLE ADD
SQL statement. Defragmentation enables you to remove the secondary table partitions and create a single table partition that contains all of the table columns. When secondary table partitions have been created, it is recommended to periodically defragment the database in order to improve space utilization and performance.
The following procedures address the different types of database fragmentation:
Offline Defragmentation of a TimesTen Scaleout Database
A TimesTen Scaleout database is defragmented as part of the export and import process.
Thus, to defragment a TimesTen Scaleout database, use the
ttGridAdmin
dbExport
and dbImport
commands. See Exporting and
Importing a Database in the Oracle TimesTen In-Memory Database Scaleout User's
Guide.
Offline Defragmentation of a TimesTen Classic Database
To defragment a TimesTen Classic database, use the
ttMigrate
utility.
At this time:
-
All the users, cache groups, and the active standby pair have been restored to
ttdb
. -
The cache groups are in
AUTOREFRESH STATE = OFF
. -
The cache agent and replication agent are not running.
Table partitions can be added when columns are added to tables with the
ALTER TABLE ADD
SQL statement. See the notes on ALTER
TABLE in the Oracle TimesTen In-Memory Database SQL
Reference. See, Avoid ALTER TABLE for performance considerations.
See ttMigrate in the Oracle TimesTen In-Memory Database Reference.
Online Defragmentation of TimesTen Classic Databases in an Active Standby Pair Replication Scheme
Use a combination of the ttMigrate -relaxedUpgrade
and
ttRepAdmin -duplicate
utilities to defragment TimesTen Classic
databases (with minimal overall service downtime) that are involved in a replication scheme
where TABLE DEFINITION CHECKING
is set to RELAXED
. In
addition, the ttMigrate -relaxedUpgrade
option condenses
partitions.
Note:
If your TimesTen Classic database uses an active standby pair replication scheme, then you can only defragment these databases if the active standby pair replication scheme either does not contain any cache groups or contains only READONLY
cache groups.
The following sections describe how to defragment TimesTen Classic databases that are involved in an active standby pair replication scheme:
The example in this section shows how to perform an online defragmentation with an active standby pair replication scheme where the active database is ttdb1
and the standby database is ttdb2
.
Note:
The examples provided in each section assume that you are familiar with the configuration and management of replication schemes. See Getting Started in the Oracle TimesTen In-Memory Database Replication Guide.
Migrate and Rebuild the Standby Database
This section shows how to stop replication to the standby TimesTen database, save a copy of the standby database, and then defragment the standby database.
Note:
While the standby database is defragmented, application processing can continue on the active database.
Perform the following to save a copy of the standby database:
The standby database (ttdb2
) has been defragmented and both the active and standby databases are functional.
Reverse the Active and Standby Roles
In order to perform the database defragmentation on the active database, switch the roles of the active and standby database.
The active (ttdb1
) becomes the standby database. The
original standby (ttdb2
) becomes the active database.
This database now acts as the standby database in the active standby pair.
Destroy and Re-Create a New Standby
You can destroy and recreate a new standby by duplicating the new active with the
ttRepAdmin -duplicate
command.
During these steps, application processing can continue at the active database.
This process defragments both the active and standby databases with only a few seconds of service interruption.
Online Defragmentation of TimesTen Classic Databases in a Non Active Standby Pair Replication Scheme
Use a combination of the ttMigrate -relaxedUpgrade
and ttRepAdmin -duplicate
utilities to defragment TimesTen Classic databases (with minimal overall service downtime) that are involved in a replication scheme where TABLE DEFINITION CHECKING
is set to RELAXED
. In addition, the ttMigrate -relaxedUpgrade
option condenses partitions.
Note:
The examples provided in each section assume that you are familiar with the configuration and management of replication schemes. For more information, see Getting Started in the Oracle TimesTen In-Memory Database Replication Guide.
The following sections describe how to defragment TimesTen Classic databases that are involved in a non active standby pair replication scheme:
Note:
These sections discuss how to defragment databases that are involved in a bidirectional replication scheme. In bidirectional replication schemes, each database is both a master and subscriber.
The examples in this section show how to perform an online defragmentation with bidirectional and unidirectional replication schemes with two TimesTen databases named ttdb1
and ttdb2
. For the unidirectional replication example, ttdb1
represents the master and ttdb2
represents the subscriber.
Migrate and Rebuild a Database
The first step in the procedure is to stop replication on one of the TimesTen Classic databases and then defragment this database.
Note:
While one of the databases is defragmented, application processing can continue on the other database.
Perform the following to save a copy of the database:
The ttdb2
TimesTen database has been defragmented.
Alter the Replication Scheme
In order to perform the database defragmentation on the ttdb1
database, perform the following:
If you modified a unidirectional replication scheme, the ttdb2
database now acts as the master database in the unidirectional scheme; the ttdb1
database acts as the subscriber database in the unidirectional replication scheme.
Destroy and Re-Create a Database
Destroy and recreate the TimesTen database in the replication scheme that has not yet
been defragmented using ttRepAdmin -duplicate
.
During these steps, application processing can continue on the defragmented database.
This process defragments both of the TimesTen Classic databases involved in either a unidirectional or bidirectional replication scheme with only a few seconds of service interruption.