Cache Guide
Cache Guide
Cache Guide
Database
Cache Guide
Release 22.1
F35392-06
February 2023
Oracle TimesTen In-Memory Database Cache Guide, Release 22.1
F35392-06
This software and related documentation are provided under a license agreement containing restrictions on
use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your
license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license,
transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse
engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is
prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-free. If
you find any errors, please report them to us in writing.
If this is software, software documentation, data (as defined in the Federal Acquisition Regulation), or related
documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S.
Government, then the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs (including any operating system, integrated software,
any programs embedded, installed, or activated on delivered hardware, and modifications of such programs)
and Oracle computer documentation or other Oracle data delivered to or accessed by U.S. Government end
users are "commercial computer software," "commercial computer software documentation," or "limited rights
data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental
regulations. As such, the use, reproduction, duplication, release, display, disclosure, modification, preparation
of derivative works, and/or adaptation of i) Oracle programs (including any operating system, integrated
software, any programs embedded, installed, or activated on delivered hardware, and modifications of such
programs), ii) Oracle computer documentation and/or iii) other Oracle data, is subject to the rights and
limitations specified in the license contained in the applicable contract. The terms governing the U.S.
Government's use of Oracle cloud services are defined by the applicable contract for such services. No other
rights are granted to the U.S. Government.
This software or hardware is developed for general use in a variety of information management applications.
It is not developed or intended for use in any inherently dangerous applications, including applications that
may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you
shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its
safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this
software or hardware in dangerous applications.
Oracle®, Java, and MySQL are registered trademarks of Oracle and/or its affiliates. Other names may be
trademarks of their respective owners.
Intel and Intel Inside are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are
used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Epyc,
and the AMD logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered
trademark of The Open Group.
This software or hardware and documentation may provide access to or information about content, products,
and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly
disclaim all warranties of any kind with respect to third-party content, products, and services unless otherwise
set forth in an applicable agreement between you and Oracle. Oracle Corporation and its affiliates will not be
responsible for any loss, costs, or damages incurred due to your access to or use of third-party content,
products, or services, except as set forth in an applicable agreement between you and Oracle.
Contents
What's New
New features in Release 22.1.1.1.0 xii
1 Cache Concepts
Overview of Cache Groups 1-1
Cache Instance 1-3
Cache Group Types 1-3
Transmitting Changes Between the TimesTen and Oracle Databases 1-5
Using Oracle GoldenGate as an Alternative Cache Refresh Mechanism 1-7
High Availability Caching Solution 1-8
2 Getting Started
Setting Up the Oracle Database and TimesTen Classic Systems 2-1
Set Up Users in the Oracle Database 2-2
Create a DSN for the TimesTen Database 2-3
Set the Net Service Name for the Oracle Database in the tnsnames.ora File 2-4
Create Users in the TimesTen Database 2-4
Set the Cache Administration User Name and Password in the TimesTen Database 2-6
Creating Cache Groups 2-6
Identify the Oracle Database Tables To Be Cached 2-7
Start the Cache Agent 2-9
Create the Cache Groups 2-9
Start the Replication Agent for the AWT Cache Group 2-11
Performing Operations on the Read-Only Cache Group 2-11
Manually Load the Cache Group 2-11
Update the Cached Oracle Database Table 2-12
Performing Operations on a Dynamically Updatable Cache Group 2-13
Dynamically Load the Cache Group 2-14
Update the TimesTen Cache Table 2-14
Cleaning Up the TimesTen Classic and Oracle Database Systems 2-16
Stop the Replication Agent 2-16
iii
Drop the Cache Groups 2-16
Stop the Cache Agent and Destroy the TimesTen Database 2-16
Drop the Oracle Database Users and Their Objects 2-17
iv
Configuring Parallel Propagation to the Oracle Database 4-16
What an AWT Cache Group Does and Does Not Guarantee 4-16
Restrictions With AWT Cache Groups 4-17
Reporting Oracle Database Permanent Errors for AWT Cache Groups 4-18
Synchronous WriteThrough (SWT) Cache Group 4-20
Restrictions With SWT Cache Groups 4-22
Hybrid Cache Group 4-23
Creating a Hybrid Cache Group 4-24
Specifying the Dynamic Load for a Hybrid Cache Group 4-25
Automatic Passthrough for Hybrid Cache Groups 4-28
Restrictions for a Dynamic Hybrid Read-Only Cache Group 4-28
User Managed Cache Group 4-28
READONLY Cache Table Attribute 4-29
PROPAGATE Cache Table Attribute 4-30
Examples of User Managed Cache Groups 4-32
Using a WHERE Clause 4-36
Proper Placement of WHERE Clause in a CREATE CACHE GROUP Statement 4-37
Referencing Oracle Database PL/SQL Functions in a WHERE Clause 4-38
Specifying Automatic Refresh With the AUTOREFRESH Cache Group Attribute 4-39
Creating a Dynamic Cache Group With the DYNAMIC Keyword 4-39
Creating a Hash Index on the Primary Key Columns of the Cache Table 4-39
ON DELETE CASCADE Cache Table Attribute 4-40
Caching Oracle Database Synonyms 4-40
Caching Oracle Database LOB Data 4-41
Restrictions on Caching Oracle Database LOB Data 4-42
Implementing Aging in a Cache Group for TimesTen Classic 4-42
LRU Aging in TimesTen Classic 4-43
Time-Based Aging in TimesTen Classic 4-44
Manually Scheduling an Aging Process in TimesTen Classic 4-46
Configuring a Sliding Window in TimesTen Classic 4-46
Replicating Cache Tables in TimesTen Classic 4-47
Create and Configure the Active Database 4-48
Create and Configure the Standby Database 4-50
Create and Configure the Read-Only Subscriber Database 4-51
v
Improving the Performance of Loading or Refreshing a Large Number of Cache
Instances 5-4
Example of Manually Loading and Refreshing a Static Cache Group 5-5
Example of Manually Loading and Refreshing a Dynamic Cache Group 5-6
Flushing a User Managed Cache Group 5-8
Unloading a Cache Group 5-9
Automatically Refreshing a Cache Group 5-9
AUTOREFRESH Cache Group Attribute Overview 5-10
Autorefresh Mode Attribute Settings 5-10
Autorefresh Interval and State Settings 5-11
Restrictions for Autorefresh 5-12
Altering a Cache Group to Change the AUTOREFRESH Mode, Interval or State 5-13
Manually Creating Oracle Database Objects for Cache Groups With Autorefresh 5-14
Initiating an Immediate Autorefresh in TimesTen Classic 5-15
Disabling Full Autorefresh for Cache Groups 5-16
Loading and Refreshing a Static Cache Group With Autorefresh 5-17
Loading and Refreshing a Dynamic Cache Group With Autorefresh 5-18
Manually or Dynamically Loading Cache Groups 5-19
Dynamic Cache Groups 5-20
Enabling or Disabling Dynamic Load 5-22
Guidelines for Dynamic Load 5-22
Examples of Dynamic Load of a Single Cache Instance 5-24
Dynamically Loading Multiple Cache Instances 5-27
Dynamically Loading Multiple Cache Instances With Multiple Primary Keys 5-27
Dynamically Loading Multiple Cache Instances Without Multiple Primary Keys 5-28
Returning Errors for Dynamic Load 5-30
Determining the Number of Cache Instances Affected by an Operation 5-31
Setting a Passthrough Level 5-31
PassThrough=0 5-32
PassThrough=1 5-32
PassThrough=2 5-33
PassThrough=3 5-34
Considerations for Using Passthrough 5-35
Changing the Passthrough Level for a Connection or Transaction 5-36
Automatic Passthrough of Dynamic Load to the Oracle Database 5-36
vi
Managing a Cache Environment With Oracle Database Objects 6-4
Monitoring Cache Groups 6-6
Using the ttIsql Utility cachegroups Command 6-7
Monitoring Autorefresh Operations on Cache Groups 6-8
Monitoring AWT Cache Groups 6-8
Configuring a Transaction Log File Threshold for AWT Cache Groups 6-8
Tracking DDL Statements Issued on Cached Oracle Database Tables 6-9
Dropping Oracle Database Objects Used by Cache Groups With Autorefresh 6-10
Impact on Cache Groups When Modifying the Oracle Database Schema 6-12
Impact of Failed Autorefresh Operations on TimesTen Databases 6-12
Managing the Cache Administration User's Tablespace 6-16
Defragmenting Change Log Tables in the Tablespace 6-16
Manually Defragmenting the Change Log Tables for Cache Groups With
Autorefresh 6-19
Receiving Notification on Tablespace Usage 6-19
Recovering From a Full Tablespace 6-20
Backing Up and Restoring a TimesTen Classic Database With Cache Groups 6-21
Backing Up and Restoring Using the ttBackup and ttRestore Utilities 6-21
Backing Up and Restoring TimesTen Classic Database With the ttMigrate Utility 6-23
Changing Cache User Names and Passwords 6-26
7 Cache Performance
Dynamic Load Performance 7-1
Managing a Cache Connection Pool to the Oracle Database for Dynamic Load
Requests 7-2
Enable the Cache Connection Pool 7-3
Size the Cache Connection Pool 7-5
Use the ChildServer Connection Attribute to Identify a Child Server Process 7-6
Dynamically Applying Cache Connection Pool Sizing Modifications 7-6
Example Demonstrating Management of the Cache Connection Pool 7-7
Limiting the Number of Connections to the Oracle Database 7-8
Restrictions for the Cache Connection Pool 7-9
Improving AWT Throughput 7-9
Improving AWT Throughput With Parallel Propagation to the Oracle Database 7-10
Table Constraint Restrictions When Using Parallel Propagation for AWT Cache
Groups 7-12
Manually Initiate Check for Missing Constraints for an AWT Cache Group 7-15
Configuring Batch Size for Parallel Propagation for AWT Cache Groups 7-16
Improving AWT Throughput With SQL Array Processing 7-17
Improving Performance for Autorefresh Operations 7-17
Minimizing Delay for Cached Data With Continuous Autorefresh 7-18
vii
Reducing Contention for Dynamic Read-Only Cache Groups With Incremental
Autorefresh 7-18
Requirements for Setting DynamicLoadReduceContention 7-19
Reducing Lock Contention for Read-Only Cache Groups With Autorefresh and
Dynamic Load 7-19
Options for Reducing Contention Between Autorefresh and Dynamic Load Operations 7-20
Improving Performance When Reclaiming Memory During Autorefresh Operations 7-21
Running Large Transactions With Incremental Autorefresh Read-Only Cache Groups 7-22
Using ttCacheAutorefreshXactLimit 7-23
Example of Potential Transactional Inconsistency 7-24
Retrieving Statistics to Evaluate Performance When a Transaction Limit is Set 7-28
Configuring a Select Limit for Incremental Autorefresh for Read-Only Cache Groups 7-28
How to Determine Which Intervals Have a Particular Select Limit 7-29
Retrieving Statistics to Evaluate Performance When Using a Select Limit 7-30
Retrieving Statistics on Autorefresh Transactions 7-30
Caching the Same Oracle Table on Two or More TimesTen Databases 7-31
viii
Failure of the Primary Oracle Database 10-9
Failure of the Primary Site 10-10
Cache in TimesTen Works With Synchronous Data Guard 10-12
Configuring the Oracle Databases for TimesTen and Synchronous Data Guard 10-12
Configuring the TimesTen Database to Work With Synchronous Data Guard 10-15
ix
API Compatibility C-2
JDBC API Compatibility C-2
java.sql.Connection C-2
java.sql.Statement C-3
java.sql.ResultSet C-3
java.sql.PreparedStatement C-3
java.sql.CallableStatement C-4
java.sql.ResultSetMetaData C-4
Stream Support C-4
ODBC API Compatibility C-5
SQL Compatibility C-5
Schema Objects C-6
Caching Oracle Database Partitioned Tables C-6
Non-Schema Objects C-7
Differences Between Oracle Database and TimesTen Tables C-7
Data Type Support C-7
SQL Operators C-8
SELECT Statements C-9
SQL Subqueries C-9
SQL Functions C-9
SQL Expressions C-11
INSERT/DELETE/UPDATE/MERGE Statements C-12
TimesTen-Only SQL and Built-In Procedures C-12
PL/SQL Constructs C-13
Mappings Between Oracle Database and TimesTen Data Types C-13
x
About This Content
This document covers TimesTen support for cache operations.
Audience
This guide is for anyone developing or supporting applications to cache data from an Oracle
database in a TimesTen database. Cache operations enable the caching of subsets of an
Oracle database into cache tables within a TimesTen database for improved response time in
the application tier. Cache tables can be read-only or updatable. Applications read and
update the cache tables using standard Structured Query Language (SQL) while data
synchronization between the TimesTen database and the Oracle database is performed
automatically.
Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility
Program website at http://www.oracle.com/pls/topic/lookup?ctx=acc&id=docacc.
Conventions
The following text conventions are used in this document.
Convention Meaning
boldface Boldface type indicates graphical user interface elements associated with an
action, or terms defined in text or the glossary.
italic Italic type indicates book titles, emphasis, or placeholder variables for which
you supply particular values.
monospace Monospace type indicates commands within a paragraph, URLs, code in
examples, text that appears on the screen, or text that you enter.
11
What's New
What's New
This section summarizes new features and functionality of TimesTen Release 22.1 that
are documented in this guide, providing links into the guide for more information.
xii
1
Cache Concepts
Use caching to improve the performance for your applications access to data. You can cache
Oracle Database data and reduce the workload on the Oracle database.
The TimesTen mechanism that enables read and write caching for Oracle database tables is
called a cache group. A cache group can represent one or more related tables on an Oracle
database. Each Oracle table is represented in the cache group with a cache table. You can
read from or write to the cache tables. TimesTen connects to the backend Oracle database to
load or update data as appropriate.
You can use cache in both TimesTen Classic and TimesTen Scaleout.
• TimesTen Classic supports all cache group types.
• TimesTen Scaleout supports static read-only cache groups.
See Cache Group Types.
This chapter includes the following topics:
• Overview of Cache Groups
• Cache Instance
• Cache Group Types
• Transmitting Changes Between the TimesTen and Oracle Databases
• Using Oracle GoldenGate as an Alternative Cache Refresh Mechanism
• High Availability Caching Solution
1-1
Chapter 1
Overview of Cache Groups
TimesTen
Cache group target_customers
customer
cust_num* region name ...
122 West Jim Johnston ...
663 MidWest Pat Reed ...
Oracle
database
customer
122 West Jim John ...
342 West Jane Stone ...
663 MidWest Pat Reed ...
942 East Terry Boone ...
You can cache multiple Oracle database tables in the same cache group by defining a
root table and one or more child tables. A cache group can contain only one root table.
The root table does not reference any table with a foreign key constraint. In a cache
group with multiple tables, each child table must reference the root table or another
child table in the same cache group using a foreign key constraint. Although tables in a
multiple-table cache group must be related to each other in the TimesTen database
through foreign key constraints, the corresponding tables in the Oracle database do
not necessarily need to be explicitly related to each other. The tables on the Oracle
database can be related:
• Explicitly through a foreign key constraint.
• Implicitly related by the user application (those that update the Oracle database).
The user application could maintain a relationship between tables that is not
enforced by the Oracle database.
See Multiple-Table Cache Group.
While you may have multiple TimesTen databases that synchronize with the same
Oracle database, they each operate independently. Thus, any data cached in separate
TimesTen databases each synchronize with the Oracle database independently.
An Oracle database table cannot be cached in separate cache groups within the same
TimesTen database. However, the table can be cached in separate cache groups
within different TimesTen databases. If the table is cached in separate cache groups
1-2
Chapter 1
Cache Instance
and the same cache instance is changed simultaneously on multiple TimesTen databases,
there is no guarantee as to the order in which the changes are propagated to the cached
Oracle database table. The contents of such cache groups in different TimesTen databases
may not be consistent at a given point in time.
Cache Instance
Data is loaded from an Oracle database into a cache group within a TimesTen database in
units called cache instances.
A cache instance is defined as a single row in the cache group's root table together with the
set of related rows in the child tables.
Figure 1-2 shows three tables in the customer_orders cache group. The root table is
customer. orders and order_item are child tables. The cache instance identified by the row
with the value 122 in the cust_num primary key column of the customer table includes:
• The two rows with the value 122 in the cust_num column of the orders table (whose value
in the ord_num primary key column is 44325 or 65432), and
• The three rows with the value 44325 or 65432 in the ord_num column of the order_item
table
TimesTen
Cache group customer_orders
customer (Root table)
cust_num region name address
orders Oracle
ord_num cust_num when_placed when_shipped database
44325 122 10/7/16 10/7/16
customer
65432 122 8/24/16 8/27/16
Child 76543 663 4/2/16 4/8/16
Tables Data for all customers
order_item orders
44325 TR3A 5
65432 FT094 1
76543 SD07 2
1-3
Chapter 1
Cache Group Types
1-4
Chapter 1
Transmitting Changes Between the TimesTen and Oracle Databases
Note:
A static cache group is one that is created without the DYNAMIC keyword.
1-5
Chapter 1
Transmitting Changes Between the TimesTen and Oracle Databases
Figure 1-3 Transmitting Committed Changes Between the TimesTen and Oracle
Databases
TimesTen
database
cache group
Flush Load
Refresh
Propagate
Dynamic load
Autorefresh
Oracle
database
The DYNAMIC keyword designates whether the cache group is a static or dynamic
cache group:
• Static cache group: Defined when the DYNAMIC keyword is not supplied when
creating the cache group. In a static cache group, cache instances are loaded
manually into the TimesTen cache tables from an Oracle database. Within a static
cache group, data is initially loaded into the cache tables from the cached Oracle
database tables using a LOAD CACHE GROUP statement. After which, you can
1-6
Chapter 1
Using Oracle GoldenGate as an Alternative Cache Refresh Mechanism
refresh the data with a REFRESH CACHE GROUP statement or automatically refresh the data
if defined to use autorefresh. Once the cache tables are loaded, the user can run queries.
A static cache group is appropriate when the set of data to cache is static and can be
predetermined before applications begin performing operations on the cache tables. By
default, cache groups are static.
• Dynamic cache group: Defined when the cache group is created with the DYNAMIC
keyword. Within a dynamic cache group, data can be loaded into the cache group from
an Oracle database either dynamically on demand or manually with LOAD CACHE GROUP or
REFRESH CACHE GROUP statements. A manual refresh or an autorefresh operation on a
dynamic cache group can result in existing cache instances being updated or deleted, but
committed changes on Oracle database data that are not being cached do not result in
new cache instances being loaded into its cache tables. A dynamic cache group is
appropriate when the set of data you need to cache is small compared to the full size of
the data that exists in the tables in the Oracle database.
The data should be preloaded from the Oracle database before applications perform
operations on the cache tables.
Choose static or dynamic load when deciding how much data you want to cache. Ideally, a
manual load is faster. Use dynamic load to automate loading new data or to specify how
much data to load into memory.
Any cache group type (read-only, AWT, SWT, user managed) can be defined as a static
cache group. All cache group types except a user managed cache group that uses both the
AUTOREFRESH cache group attribute and the PROPAGATE cache table attribute can be defined as
a dynamic cache group.
See Methods for Transmitting Changes Between TimesTen and Oracle Databases.
See Asynchronous WriteThrough (AWT) Cache Group and Synchronous WriteThrough
(SWT) Cache Group.
1-7
Chapter 1
High Availability Caching Solution
1-8
2
Getting Started
Getting Started provides a demonstration of how to create and use cache groups in TimesTen
Classic.
See Using Cache Groups in TimesTen Scaleout in the Oracle TimesTen In-Memory Database
Scaleout User's Guide for an illustration of the creation and use of static read-only cache
groups in TimesTen Scaleout.
This chapter demonstrates how to create a static read-only local cache group and a dynamic
updatable cache group in TimesTen Classic. In addition, this chapter describes how to
populate cache tables, and how to observe the transfer of updates between the cache tables
in the TimesTen database and the cached tables in the Oracle database.
• Setting Up the Oracle Database and TimesTen Classic Systems
• Creating Cache Groups
• Performing Operations on the Read-Only Cache Group
• Performing Operations on a Dynamically Updatable Cache Group
• Cleaning Up the TimesTen Classic and Oracle Database Systems
Note:
You must always install the TimesTen and Oracle databases on separate systems
to avoid negative performance results and resource contention between them for
memory, CPU time and disk I/O.
When using cache, TimesTen must know which Oracle database to connect to, which
credentials to use when connecting to the Oracle database and which users own the tables in
both TimesTen and Oracle databases.
1. Set Up Users in the Oracle Database.
2. Create a DSN for the TimesTen Database.
3. Set the Net Service Name for the Oracle Database in the tnsnames.ora File.
4. Create Users in the TimesTen Database.
5. Set the Cache Administration User Name and Password in the TimesTen Database.
2-1
Chapter 2
Setting Up the Oracle Database and TimesTen Classic Systems
Tablespace created.
Note:
See the comments in the grantCacheAdminPrivileges.sql script for
the required privileges by the user who runs this script and the
privileges that this user grants to the cache administration user.
2-2
Chapter 2
Setting Up the Oracle Database and TimesTen Classic Systems
The privileges that the cache administration user requires depend on the types of
cache groups you create and the operations that you perform on the cache groups.
4. Grant additional privileges required for caching to the existing schema owner that owns
the tables you want to cache. In the following example, the schema owner is sales:
SQL> GRANT CREATE SESSION, CREATE TRIGGER, CREATE SEQUENCE, CREATE TYPE, CREATE
PROCEDURE, CREATE TABLE
TO sales;
See Create the Oracle Database Users and Default Tablespace for more information about
the schema owner and the cache administration user.
On UNIX or Linux, in the .odbc.ini file that resides in your home directory or the
timesten_home/conf/sys.odbc.ini file, create a TimesTen DSN cache1 and set the
following connection attributes:
[cache1]
DataStore=/users/OracleCache/ttcache
PermSize=64
OracleNetServiceName=oracledb
DatabaseCharacterSet=AL32UTF8
On Windows, create a TimesTen user DSN or system DSN cache1 and set the following
connection attributes:
• Data Store Path + Name: c:\\temp\ttcache
• Permanent Data Size: 64
• Oracle Net Service Name: oracledb
• Database Character Set: AL32UTF8
Use the default settings for all the other connection attributes.
See Define a DSN for the TimesTen Classic Database for more information about defining a
DSN for a TimesTen database that caches data from an Oracle database.
See Managing TimesTen Databases in Oracle TimesTen In-Memory Database Operations
Guide for more information about TimesTen DSNs.
Note:
The term "data store" is used interchangeably with "TimesTen database".
2-3
Chapter 2
Setting Up the Oracle Database and TimesTen Classic Systems
Set the Net Service Name for the Oracle Database in the
tnsnames.ora File
In order to connect to the Oracle database, its net service name needs to be added to
the tnsnames.ora file.
1. Set the TNS_ADMIN location for the cache agent with the ttInstanceModify -
tnsadmin option to set the path to the tnsnames.ora file. Specify the full path to
the directory where the file is located.
ttInstanceModify -tnsadmin /TimesTen/conf
2. For cache in TimesTen Classic, set the TNS_ADMIN environment variable to indicate
the full path to the directory where the tnsnames.ora file is located. Set this
variable in the user's profile script so that it persists.
export TNS_ADMIN=/TimesTen/tnsadmin
Add the net service name for the Oracle Database to the tnsnames.ora file. The
following is an example of defining orcl in a tnsnames.ora file:
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost)
(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = myhost.example.com)))
2-4
Chapter 2
Setting Up the Oracle Database and TimesTen Classic Systems
sales sales
owner of same name schema owner
cache tables of tables
cacheadmin cacheadmin
cache same name cache
administration administration
user user
• A TimesTen cache administration user performs cache group operations. The TimesTen
cache administration user must have the same name as the companion Oracle Database
cache administration user that can access the cached Oracle Database tables. The
password of the TimesTen cache administration user can be different than the password
of the companion Oracle Database cache administration user with the same name.
Typically, the companion Oracle Database user is the cache administration user. But it
can also be a schema owner or some other existing user. For ease of use, making the
cache administration user the companion Oracle Database user of the cache
administration user is preferable.
Note:
See Create the TimesTen Users for more details on the TimesTen cache
administration user and its companion Oracle Database cache administration
user.
• One or more cache table owner users that own the cache tables. You must create a user
that owns the TimesTen cache tables that has the same name as the schema owner that
owns Oracle Database tables to be cached in the TimesTen database. The password of a
cache table user can be different than the password of the Oracle Database schema
owner with the same name.
The names of all TimesTen cache tables have the same names of the corresponding
cached Oracle Database tables.
Use the ttIsql utility on the TimesTen system from an operating system shell or command
prompt as the instance administrator, and connect to the cache1 DSN to create the TimesTen
database that is to be used to cache data from an Oracle database:
% ttIsql cache1
Use ttIsql to create a cache administration user on TimesTen. Grant this user the minimum
set of privileges required to create cache groups and to perform operations on the cache
2-5
Chapter 2
Creating Cache Groups
groups. In the following example, the cache administration user name is cacheadmin,
which is the same name as the Oracle Database cache administration user that was
created earlier:
Command> CREATE USER cacheadmin IDENTIFIED BY ttpwd;
Command> GRANT CREATE SESSION, CACHE_MANAGER, CREATE ANY TABLE TO cacheadmin;
Then, use ttIsql to create a cache table user. In the following example, the cache
table user name is sales, which is the same name as the schema owner that owns the
Oracle database tables that are to be cached.
Command> CREATE USER sales IDENTIFIED BY ttpwd;
Command> exit
The privileges that the cache administration user requires depend on the types of
cache groups you create and the operations that you perform on the cache groups.
See Create the TimesTen Users for more information about the cache administration
user and the cache table users.
See Authentication in TimesTen and Authorization in TimesTen in Oracle TimesTen In-
Memory Database Security Guide for more information about TimesTen users and
privileges.
In the connection string, specify the TimesTen cache administration user name in the
UID connection attribute. Specify the TimesTen cache administration user's password
in the PWD connection attribute. Specify the password of the Oracle Database cache
administration user in the OraclePWD connection attribute within the connection string.
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=ttpwd;OraclePWD=orapwd"
Use ttIsql to call the ttCacheUidPwdSet built-in procedure to set the Oracle
Database cache administration user name and password:
Command> call ttCacheUidPwdSet('cacheadmin','orapwd');
The Oracle Database cache administration user name and password need to be set
only once in a TimesTen database. See Set the Cache Administration User Name and
Password.
2-6
Chapter 2
Creating Cache Groups
Cache Cache
group group
tables tables
Cache Cache
group group
tables tables
Complete the following tasks to create a read-only cache group and an AWT cache group:
1. Identify the Oracle Database Tables To Be Cached.
2. Start the Cache Agent.
3. Create the Cache Groups.
4. Start the Replication Agent for the AWT Cache Group.
Use SQL*Plus to create a table readtab as shown in Figure 2-3, and a table writetab as
shown in Figure 2-4:
SQL> CREATE TABLE readtab (keyval NUMBER NOT NULL PRIMARY KEY, str VARCHAR2(32));
SQL> CREATE TABLE writetab (pk NUMBER NOT NULL PRIMARY KEY, attr VARCHAR2(40));
2-7
Chapter 2
Creating Cache Groups
Application
...
Oracle
database
readtab
1 Hello
2 World
Application
...
Oracle
database
writetab
100 Oracle
101 CACHE
2-8
Chapter 2
Creating Cache Groups
Then use SQL*Plus to insert some rows into the readtab and writetab tables, and commit
the changes:
SQL> INSERT INTO readtab VALUES (1, 'Hello');
SQL> INSERT INTO readtab VALUES (2, 'World');
Next use SQL*Plus to grant the SELECT privilege on the readtab table, and the SELECT,
INSERT, UPDATE and DELETE privileges on the writetab table to the cache administration user:
SQL> GRANT SELECT ON readtab TO cacheadmin;
The SELECT privilege on the readtab table is required to create a read-only cache group that
caches this table and to perform autorefresh operations from the cached Oracle Database
table to the TimesTen cache table.
The SELECT privilege on the writetab table is required to create an AWT cache group that
caches this table. The INSERT, UPDATE, and DELETE privileges on the writetab table are
required to run write through operations from the TimesTen cache table to the cached Oracle
Database table.
See Grant Privileges to the Oracle Cache Administration User for more information about the
privileges required for the cache administration user to create and perform operations on a
read-only cache group and an AWT cache group.
2-9
Chapter 2
Creating Cache Groups
The cache groups readcache and writecache, and their respective cache tables
sales.readtab and sales.writetab, whose table owners and table names are
identical to the cached Oracle Database schema and tables, are created in the
TimesTen database. Figure 2-5 shows that the writecache cache group caches the
sales.writetab table.
Application
...
CREATE READONLY
CACHE GROUP writecache ...
TimesTen
Oracle
database
database
TimesTen cache
sales.writetab
100 Oracle writetab
101 CACHE
100 Oracle
101 CACHE
writecache
Use the ttIsql cachegroups command to view the definition of the readcache and
writecache cache groups:
Command> cachegroups;
2-10
Chapter 2
Performing Operations on the Read-Only Cache Group
Autorefresh: No
Aging: LRU on
See Read-Only Cache Group for more information about read-only cache groups.
See Asynchronous WriteThrough (AWT) Cache Group for more information about AWT
cache groups.
See Creating a Dynamic Cache Group With the DYNAMIC Keyword for more information
about dynamic cache groups.
The replication agent propagates committed changes on TimesTen cache tables in AWT
cache groups to the cached Oracle Database tables.
See Starting and Stopping the Replication Agent.
Figure 2-6 shows that the Oracle database data is loaded into the sales.readtab cache
table.
2-11
Chapter 2
Performing Operations on the Read-Only Cache Group
TimesTen Oracle
database database
TimesTen cache
sales.readtab
Load Cache Group
1 Hello readtab
2 World 1 Hello
2 World
readcache
Start the ttIsql utility and connect to the cache1 DSN as the instance administrator.
Use ttIsql to grant the SELECT privilege on the sales.readtab cache table to the
TimesTen cache administration user so that this user can issue a SELECT query on this
table.
% ttIsql cache1
Command> GRANT SELECT ON sales.readtab TO cacheadmin;
Command> exit
Start the ttIsql utility and connect to the cache1 DSN as the TimesTen cache
administration user, including the TimesTen cache administration user password and
the Oracle cache administration user password. Use ttIsql to query the contents of
sales.readtab cache table.
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> SELECT * FROM sales.readtab;
< 1, Hello >
< 2, World >
2 rows found.
Since the read-only cache group was created specifying autorefresh with an interval of
5 seconds, the sales.readtab cache table in the readcache cache group is
automatically refreshed after 5 seconds with the committed changes on the cached
Oracle Database sales.readtab table as shown in Figure 2-7.
2-12
Chapter 2
Performing Operations on a Dynamically Updatable Cache Group
Figure 2-7 Automatically Refresh the Cache Table With Oracle Database Updates
Application
...
TimesTen Oracle
database database
TimesTen cache
readcache
As the TimesTen cache administration user, use the ttIsql utility to query the contents of the
sales.readtab cache table after the readcache cache group has been automatically
refreshed with the committed changes on the cached Oracle database table:
Command> SELECT * FROM sales.readtab;
< 1, Hi >
< 3, Welcome >
2 rows found.
Command> exit
2-13
Chapter 2
Performing Operations on a Dynamically Updatable Cache Group
Grant the SELECT privilege on the sales.writetab cache table to the TimesTen cache
administration user so that this user can issue a dynamic load SELECT statement on
this table.
% ttIsql cache1
Command> GRANT SELECT ON sales.writetab TO cacheadmin;
Command> exit
Start the ttIsql utility and connect to the cache1 DSN as the TimesTen cache
administration user, including the cache administration user password and the
password of its companion Oracle cache administration user. Use ttIsql to load a
cache instance on demand from the Oracle Database sales.writetab table to the
TimesTen sales.writetab cache table in the writecache cache group.
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> SELECT * FROM sales.writetab WHERE pk=100;
< 100, TimesTen >
1 row found.
Command> exit
In a dynamic cache group, a cache instance can be loaded into its cache tables on
demand with a dynamic load statement. A SELECT, UPDATE, DELETE or INSERT
statement issued on a TimesTen cache table that uniquely identifies a cache instance
results in the cache instance being automatically loaded from the cached Oracle
Database table if the data is not found in the cache table.
Data can also be explicitly loaded into the cache tables of a dynamic cache group
using a LOAD CACHE GROUP statement.
Use the ttIsql utility to connect to the cache1 DSN as the cache administration user.
Insert a new row, delete an existing row, update an existing row in the sales.writetab
cache table, and commit the changes.
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> INSERT INTO sales.writetab VALUES (102, 'Cache');
2-14
Chapter 2
Performing Operations on a Dynamically Updatable Cache Group
The committed changes on the sales.writetab cache table in the writecache cache group
are automatically propagated to the Oracle Database sales.writetab table as shown in
Figure 2-8.
Application
...
TimesTen Oracle
database database
TimesTen cache
sales.writetab
Writethrough
(automatic propagate)
100
101
Oracle
CACHE
writetab
100 Oracle
101 CACHE
writecache
As the Oracle database schema user, use SQL*Plus to query the contents of the writetab
table:
SQL> SELECT * FROM writetab;
PK ATTR
---------- -------------------------------
100 Oracle
102 Cache
SQL> exit
2-15
Chapter 2
Cleaning Up the TimesTen Classic and Oracle Database Systems
Grant the DROP ANY TABLE privilege to the TimesTen cache administration user so that
this user can drop the underlying cache tables when dropping the cache groups.
% ttIsql cache1
Command> GRANT DROP ANY TABLE TO cacheadmin;
Command> exit
Start the ttIsql utility and connect to the cache1 DSN as the TimesTen cache
administration user. Use ttIsql to drop the readcache read-only cache group and the
writecache AWT cache group.
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> DROP CACHE GROUP readcache;
Command> DROP CACHE GROUP writecache;
The cache groups readcache and writecache, and their respective cache tables
sales.readtab and sales.writetab, are dropped from the TimesTen database.
2-16
Chapter 2
Cleaning Up the TimesTen Classic and Oracle Database Systems
Specifying CASCADE in a DROP USER statement drops all objects such as tables and triggers
owned by the user before dropping the user itself.
Next, use SQL*Plus to drop the TT_CACHE_ADMIN_ROLE role:
SQL> DROP ROLE TT_CACHE_ADMIN_ROLE;
Then, use SQL*Plus to drop the default tablespace cachetblsp used by the cache
administration user including the contents of the tablespace and its data file:
SQL> DROP TABLESPACE cachetblsp INCLUDING CONTENTS AND DATAFILES;
SQL> exit
2-17
3
Setting Up a Caching Infrastructure
Before you can start caching Oracle database data in a TimesTen database, you must first
install TimesTen.
Follow the instructions provided in Overview of the Installation Process in TimesTen Classic
in the Oracle TimesTen In-Memory Database Installation, Migration, and Upgrade Guide.
After which, perform these tasks for setting up the TimesTen and Oracle database systems:
• Configuring the Oracle Database to Cache Data
• Configuring a TimesTen Database to Cache Oracle Database Data
• Testing the Connectivity Between the TimesTen and Oracle Databases
• Managing the Cache Agent
Note:
You cannot use the Oracle Autonomous Database for transaction processing (ATP)
as a source for caching data in TimesTen. In addition, if you are using a multitenant
container database (CDB) or pluggable database (PDB), note the specific
instructions below on how to create the cache administration user and grant this
user privileges in a CDB or PDB.
3-1
Chapter 3
Configuring the Oracle Database to Cache Data
Note:
See Managing a Cache Environment With Oracle Database Objects for
a list of Oracle database tables used by the cache administration user.
Note:
The use of the sys@tnsservicename as sysdba user in this example is
applicable only for a test environment.
% cd timesten_home/install/oraclescripts
% sqlplus sys@tnsservicename as sysdba
Enter password: password
SQL> CREATE TABLESPACE cachetblsp DATAFILE 'tt_cache.f' SIZE 5G
SEGMENT SPACE MANAGEMENT AUTO;
Tablespace created.
2. Create a cache administration user that creates, owns, and maintains Oracle
database objects that store information used to manage the cache environment for
a TimesTen database and enforce predefined behaviors of particular cache group
types.
If you are using a multitenant container database (CDB) or pluggable database
(PDB), the cache administrator user can be one of the following:
• Local user: A local user is a database user that can operate only within a
single PDB. You must assign cache privileges only within the PDB in which
this user exists.
• Common user: A common user is a database user known in every container
and has the same identity in the CBD root and in every existing and future
PDB in the CDB. You must assign cache privileges within each PDB in the
CDB in which you want to use cache.
3-2
Chapter 3
Configuring the Oracle Database to Cache Data
Note:
Each TimesTen database can be managed by only a single cache
administration user on the Oracle database. However, a single cache
administration user can manage multiple TimesTen databases. You can specify
one or more cache administration users where each manages one or more
TimesTen databases.
See Caching the Same Oracle Table on Two or More TimesTen Databases.
Designate the tablespace as the default tablespace for the cache administration user.
This user creates tables in this tablespace that are used to store information about the
cache environment and its cache groups. Other Oracle Database objects (such change
log tables, replication metadata tables, and triggers) are used to enforce the predefined
behaviors of cache groups with autorefresh and AWT cache groups are created in the
same tablespace. To create and manage these objects, the cache administration user
must have a high level of privileges. A cache group with autorefresh refers to a read-only
cache group or a user managed cache group that uses the AUTOREFRESH MODE
INCREMENTAL cache group attribute.
See Managing a Cache Environment With Oracle Database Objects for a list of Oracle
Database tables and triggers owned by the cache administration user.
Note:
If you create multiple cache administration users, each may use the same or
different tablespace as their default tablespace.
As the sys user, use SQL*Plus to create the Oracle database cache administration user
cacheadmin. In the following example, the default tablespace for the cacheadmin user is
cachetblsp.
SQL> CREATE USER cacheadmin IDENTIFIED BY orapwd
DEFAULT TABLESPACE cachetblsp QUOTA UNLIMITED ON cachetblsp;
3. Identify one or more existing schemas (or create a new schema) with schema owners
that own Oracle database tables that are to be cached in a TimesTen database. The
tables to be cached may or may not already exist.
Grant the schema owner the minimum set of privileges required to create tables in the
Oracle database to be cached in a TimesTen database.
This example will cache tables owned by the sales schema owner. As the sys user, the
following SQL*Plus example grants the necessary privileges required to this user.
SQL> GRANT CREATE SESSION, CREATE TABLE, CREATE CLUSTER, CREATE INDEXTYPE, CREATE
OPERATOR
TO sales;
3-3
Chapter 3
Configuring the Oracle Database to Cache Data
• If the cache administrator user is a local user: You must assign cache privileges
only within the PDB in which this user exists. This is the preferred method.
• If the cache administrator user is a common user: You must assign cache
privileges within each PDB in the CDB in which you want to use cache. Do not run
the SQL*Plus script to grant privileges to the common user in the CBD root.
See Create Oracle Database Objects Used to Manage Data Caching.
The entire list of privileges required for this user for each cache operation are listed in
Required Privileges for Cache Operations.
3-4
Chapter 3
Configuring the Oracle Database to Cache Data
See Required Privileges for Cache Operations for a complete list of privileges that need to be
granted to the cache administration user in order to perform particular cache group and
cache table operations.
Run the timesten_home/install/oraclescripts/grantCacheAdminPrivileges.sql as the
sys user. The cache administration user name is passed as an argument to the
grantCacheAdminPrivileges.sql script.
Note:
Alternatively, you can create these objects as described in The
initCacheAdminSchema.sql Script before performing any cache group operations if,
for security purposes, you do not want to grant certain privileges to the cache
administration user required to automatically create objects necessary for managing
autorefresh.
In addition to the privileges granted to the cache administration user by running the
grantCacheAdminPrivileges.sql script, this user may also need to be granted privileges
such as SELECT or INSERT on the cached Oracle Database tables depending on the types of
cache groups you create, and the operations that you perform on the cache groups and their
cache tables.
As the sys user, use SQL*Plus to run the grantCacheAdminPrivileges.sql script to grant
privileges to the cache administration user. The cache administration user then automatically
creates Oracle Database objects used to manage caching Oracle Database data in a
TimesTen database.
The grantCacheAdminPrivileges.sql script requires the Oracle database cache
administration user name as input, which is cacheadmin in this example.
SQL> @grantCacheAdminPrivileges "cacheadmin"
SQL> exit
For example, with cache groups with autorefresh, the Oracle database objects used to
enforce the predefined behaviors of these cache group types are automatically created if the
objects do not already exist and one of the following occurs:
• The cache group is created with its autorefresh state set to PAUSED or ON.
• The cache group is created with its autorefresh state set to OFF and then altered to either
PAUSED or ON.
3-5
Chapter 3
Configuring a TimesTen Database to Cache Oracle Database Data
Other Oracle database objects associated with Oracle database tables that are
cached in a cache group with autorefresh are needed to enforce the predefined
behaviors of these cache group types. See Manually Creating Oracle Database
Objects for Cache Groups With Autorefresh for details about how to create these
additional objects as part of the steps for creating a cache group with autorefresh.
To view a list of the Oracle database objects created and used by TimesTen to
manage the caching of Oracle database data, run the following query in SQL*Plus as
the sys user:
SQL> SELECT owner, object_name, object_type FROM all_objects WHERE object_name
2 LIKE 'TT\___%' ESCAPE '\';
The query returns a list of tables, indexes, and triggers owned by the cache
administration user.
3-6
Chapter 3
Configuring a TimesTen Database to Cache Oracle Database Data
• UID specifies the name of the TimesTen cache administration user. The UID connection
attribute can be specified in a direct DSN, a client DSN, or a connection string.
• PWD specifies the password of the TimesTen cache administration user specified in the
UID connection attribute. The PWD connection attribute can be specified in a direct DSN, a
client DSN, or a connection string.
• OraclePWD specifies the password of the companion Oracle Database cache
administration user that has the same name as the TimesTen cache administration user
specified in the UID connection attribute.
3-7
Chapter 3
Configuring a TimesTen Database to Cache Oracle Database Data
Note:
See Create the TimesTen Users.
Set the Net Service Name for the Oracle Database in the tnsnames.ora File
For cache in TimesTen Classic, set the TNS_ADMIN environment variable to indicate the
full path to the directory where the tnsnames.ora file is located. This is for access to
Oracle Database data.
1. Set the TNS_ADMIN location for the cache agent with the ttInstanceModify -
tnsadmin option to set the path to the tnsnames.ora file. Specify the full path to
the directory where the file is located.
ttInstanceModify -tnsadmin /TimesTen/conf
2. For cache in TimesTen Classic, set the TNS_ADMIN environment variable to indicate
the full path to the directory where the tnsnames.ora file is located. Set this
variable in the user's profile script so that it will persist.
export TNS_ADMIN=/TimesTen/tnsadmin
3-8
Chapter 3
Configuring a TimesTen Database to Cache Oracle Database Data
ttDaemonAdmin -stop
ttDaemonAdmin -start
Add the net service name for the Oracle database into the tnsnames.ora file. The following is
an example of defining orcl in a tnsnames.ora file:
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = myhost)
(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = myhost.example.com)))
Note:
You can create multiple cache administration users on a TimesTen database, such
as one for each TimesTen DBA. However, you can only define a single cache
administration user on the Oracle database for this particular TimesTen database.
(You can use the same Oracle database cache administration user for all TimesTen
databases that connect to the Oracle database or define a separate cache
administration user for each TimesTen database.) If you create multiple TimesTen
cache administration users, one or more of these users can use the same Oracle
database cache administration user.
The TimesTen database cache administration user creates the cache groups. It may perform
operations such as loading or refreshing a cache group although these operations can be
performed by any TimesTen user that has sufficient privileges. The TimesTen database cache
administration user can also monitor various aspects of the caching environment, such as
asynchronous operations that are performed on cache groups such as autorefresh.
Then, you must create a user with the same name as the Oracle Database schema owner
who owns Oracle Database tables to be cached in the TimesTen database. We refer to these
users as cache table users, because the TimesTen cache tables are to be owned by these
3-9
Chapter 3
Configuring a TimesTen Database to Cache Oracle Database Data
users. Therefore, the owner and name of a TimesTen cache table is the same as the
schema owner and name of the corresponding cached Oracle Database table. The
password of a cache table user can be different than the password of the Oracle
Database schema owner with the same name.
Operations on a cache group or a cache table, such as loading a cache group or
updating a cache table, can be performed by any TimesTen user that has sufficient
privileges. In the examples throughout this guide, the TimesTen database cache
administration user performs these types of operations although these operations can
be performed by another user, such as a cache table user, that has the required
privileges. If these operations are to be performed by a TimesTen user other than the
cache administration user, the other user must have the same name as the companion
Oracle Database cache administration user that can select from and update the
cached Oracle Database tables. Connect to the TimesTen database specifying that
user's name in the UID connection attribute, and supply the corresponding TimesTen
and Oracle Database passwords in the PWD and OraclePWD connection attributes,
respectively, to perform operations on a cache group or cache table.
The following example creates the TimesTen users.
The following example uses the ttIsql utility to connect to the cache1 DSN as the
instance administrator.
• Creates the TimesTen database cache administration user cacheadmin whose
name (in this example) is the same as the Oracle database cache administration
user.
• Creates a cache table user sales whose name is the same as the Oracle
Database schema owner of the Oracle Database tables to be cached in the
TimesTen database.
% ttIsql cache1
Command> CREATE USER cacheadmin IDENTIFIED BY ttpwd;
Command> CREATE USER sales IDENTIFIED BY ttpwd;
3-10
Chapter 3
Configuring a TimesTen Database to Cache Oracle Database Data
create the underlying cache tables which are to be owned by the cache table user).
• Alter, load, refresh, flush, unload or drop a cache group requires the appropriate privilege:
– ALTER ANY CACHE GROUP
– LOAD {ANY CACHE GROUP | ON cache_group_name
– REFRESH {ANY CACHE GROUP | ON cache_group_name
– FLUSH {ANY CACHE GROUP | ON cache_group_name
– UNLOAD {ANY CACHE GROUP | ON cache_group_name
– DROP ANY CACHE GROUP and DROP ANY TABLE
• Required privileges for other cache operations, such as dynamic load, full autorefresh
and asynchronous writethrough, are listed in Required Privileges for Cache Operations.
As the instance administrator, use the ttIsql utility to grant the cacheadmin cache
administration user the required privileges:
Command> GRANT CREATE SESSION, CACHE_MANAGER, CREATE ANY TABLE TO cacheadmin;
Command> exit
Setting the Cache Administration User Name and Password in TimesTen Classic
In TimesTen Classic, you can programmatically set the Oracle cache administration user
name and password by calling the ttCacheUidPwdSet built-in procedure after connecting as
the Timesten cache administration user.
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> call ttCacheUidPwdSet('cacheadmin','orapwd');
3-11
Chapter 3
Testing the Connectivity Between the TimesTen and Oracle Databases
It can also be set from a command line by running a ttAdmin -cacheUidPwdSet utility
command as a TimesTen external user with the CACHE_MANAGER privilege:
% ttAdmin -cacheUidPwdSet -cacheUid cacheadmin -cachePwd orapwd cache1
If you do not specify the -cachePwd option, the ttAdmin utility prompts for the cache
administration user's password.
See ttAdmin in Oracle TimesTen In-Memory Database Reference.
Note:
When you connect to the TimesTen database to work with AWT or read-only
cache groups, TimesTen Classic uses the credentials set with the
ttCacheUidPwdSet built-in procedure when connecting to the Oracle
database on behalf of these cache groups.
When you connect to the TimesTen database to work with SWT or user
managed cache groups or passthrough operations, TimesTen Classic
connects to the Oracle database using the current user's credentials as the
user name and the OraclePwd connection attribute as the Oracle password.
Thus, the correct user name and Oracle database password that should be
used for connecting to the Oracle database must be set correctly in the
connection string or with the connection attributes.
See Set the Cache Administration User Name and Password in the TimesTen
Database in the Oracle TimesTen In-Memory Database Scaleout User's Guide.
3-12
Chapter 3
Managing the Cache Agent
In TimesTen Classic, the Oracle cache administration user name can also be returned from a
command line by running a ttAdmin -cacheUidGet utility command as a TimesTen external
user with the CACHE_MANAGER privilege:
% ttAdmin -cacheUidGet cache1
You can also start the cache agent from a command line by running a ttAdmin -
cacheStart utility command as a TimesTen external user with the CACHE_MANAGER
privilege:
% ttAdmin -cacheStart cache1
3-13
Chapter 3
Managing the Cache Agent
You can also stop the cache agent from a command line by running a ttAdmin -
cacheStop utility command as a TimesTen external user with the CACHE_MANAGER
privilege:
% ttAdmin -cacheStop cache1
Do not stop the cache agent immediately after you have dropped or altered a
cache group with autorefresh. Instead, wait for at least two minutes to allow the
cache agent to clean up Oracle Database objects such as change log tables and
triggers that were created and used to manage the cache group.
The ttCacheStop built-in procedure has an optional parameter and the ttAdmin -
cacheStop utility command has an option -stopTimeout that specifies how long
the TimesTen main daemon process waits for the cache agent to stop. If the cache
agent does not stop within the specified timeout period, the TimesTen daemon
stops the cache agent. The default cache agent stop timeout is 100 seconds. A
value of 0 specifies to wait indefinitely.
Note:
The TimesTen X/Open XA and Java Transaction API (JTA) implementations
do not work with cache. The start of any XA or JTA transaction fails if the
cache agent is running.
Note:
In TimesTen Scaleout, the grid manages the cache agent start policy.
3-14
Chapter 3
Managing the Cache Agent
cacheStart utility command. To manually stop a running cache agent process, call the
ttCacheStop built-in procedure or run a ttAdmin -cacheStop utility command.
When the start policy is set to always, the cache agent starts automatically when the
TimesTen main daemon process starts. With the always start policy, the cache agent cannot
be stopped when the main daemon is running unless the start policy is first changed to either
manual or norestart. Then issue a manual stop by calling the ttCacheStop built-in procedure
or running a ttAdmin -cacheStop utility command.
With the manual and always start policies, the cache agent automatically restarts when the
database recovers after a failure such as a database invalidation.
Setting the cache agent start policy to norestart means the cache agent must be started
manually by calling the ttCacheStart built-in procedure or running a ttAdmin -cacheStart
utility command, and stopped manually by calling the ttCacheStop built-in procedure or
running a ttAdmin -cacheStop utility command.
With the norestart start policy, the cache agent does not automatically restart when the
database recovers after a failure such as a database invalidation. You must restart the cache
agent manually by calling the ttCacheStart built-in procedure or running a ttAdmin -
cacheStart utility command.
Note:
See ttAdmin, ttCachePolicySet, ttCacheStart and ttCacheStop in the Oracle
TimesTen In-Memory Database Reference.
You can set the cache agent start policy in TimesTen Classic by calling the
ttCachePolicySet built-in procedure as the TimesTen cache administration user:
Command> call ttCachePolicySet('always');
It can also be set from a command line by running a ttAdmin -cachePolicy utility command
as a TimesTen external user with the CACHE_MANAGER privilege:
% ttAdmin -cachePolicy norestart cache1
3-15
4
Defining Cache Groups
There are several different types of cache groups. There are reasons for when to use each
type of cache group for different purposes, performance and availability needs. In addition,
there are different features that you can add to provide certain functionality to a specific
cache group type.
• Cache Groups and Cache Tables
• Creating a Cache Group
• Read-Only Cache Group
• Asynchronous WriteThrough (AWT) Cache Group
• Synchronous WriteThrough (SWT) Cache Group
• Hybrid Cache Group
• User Managed Cache Group
• Using a WHERE Clause
• Specifying Automatic Refresh With the AUTOREFRESH Cache Group Attribute
• Creating a Dynamic Cache Group With the DYNAMIC Keyword
• Creating a Hash Index on the Primary Key Columns of the Cache Table
• ON DELETE CASCADE Cache Table Attribute
• Caching Oracle Database Synonyms
• Caching Oracle Database LOB Data
• Implementing Aging in a Cache Group for TimesTen Classic
• Replicating Cache Tables in TimesTen Classic
4-1
Chapter 4
Cache Groups and Cache Tables
which the updates are propagated to the cached Oracle Database table. In this case,
the contents of the updated cache table may be inconsistent between the TimesTen
databases.
Before you define the cache group table, create the Oracle Database tables that are to
be cached. Each table should be either:
• An Oracle Database table with a primary key on non-nullable columns. The
TimesTen cache table primary key must be defined on the full Oracle Database
table primary key. For example, if the cached Oracle Database table has a
composite primary key on columns c1, c2 and c3, the TimesTen cache table must
also have a composite primary key on columns c1, c2 and c3.
The following example shows how to create a cache group from an Oracle
Database table with a composite primary key. The following job_history table
was created with a composite key on the Oracle database:
CREATE TABLE job_history
(employee_id NUMBER(6) NOT NULL,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
job_id VARCHAR2(10) NOT NULL,
department_id NUMBER(4),
PRIMARY KEY(employee_id, start_date));
Table created.
Create the cache group on the TimesTen database with all columns of the
composite primary key:
CREATE WRITETHROUGH CACHE GROUP job_hist_cg
FROM sales.job_history
(employee_id NUMBER(6) NOT NULL,
start_date DATE NOT NULL,
end_date DATE NOT NULL,
job_id VARCHAR2(10) NOT NULL,
department_id NUMBER(4),
PRIMARY KEY(employee_id, start_date));
• An Oracle Database table with non-nullable columns upon which a unique index is
defined on one or more of the non-nullable columns in the table. The TimesTen
cache table primary key must be defined on all of the columns in the unique index.
For example, if the unique index for the Oracle Database table is made up of
multiple columns c1, c2, and c3, the TimesTen cache table must have a composite
primary key on columns c1, c2, and c3.
The following examples show how Oracle Database unique indexes were defined
on tables with non-nullable columns.
SQL> CREATE TABLE regions(
region_id NUMBER NOT NULL,
region_name VARCHAR2(25));
Table created.
SQL> CREATE UNIQUE INDEX region_idx
ON regions(region_id);
Index created.
4-2
Chapter 4
Cache Groups and Cache Tables
Table created.
SQL> CREATE UNIQUE INDEX products_index ON products(prod_id, cust_id);
Index created.
Based on these Oracle Database tables and unique indexes, you can create cache
groups on a TimesTen database for these tables using the unique index columns as the
primary key definition as shown below:
Command> CREATE WRITETHROUGH CACHE GROUP region_cg
FROM sales.regions
(region_id NUMBER NOT NULL PRIMARY KEY,
region_name VARCHAR2(25));
A TimesTen database can contain multiple cache groups. A cache group can contain one or
more cache tables.
Creating indexes on a cache table in TimesTen can help speed up particular queries issued
on the table in the same fashion as on a TimesTen regular table. You can create non-unique
indexes on a TimesTen cache table. Do not create unique indexes on a cache table that do
not match any unique index on the cached Oracle Database table. Otherwise, it can cause
unique constraint failures in the cache table that do not occur in the cached Oracle Database
table, and result in these tables in the two databases being no longer synchronized with each
other when autorefresh operations are performed.
4-3
Chapter 4
Cache Groups and Cache Tables
TimesTen
Cache group target_customers
customer
cust_num* region name ...
122 West Jim Johnston ...
663 MidWest Pat Reed ...
Oracle
database
customer
122 West Jim John ...
342 West Jane Stone ...
663 MidWest Pat Reed ...
942 East Terry Boone ...
4-4
Chapter 4
Cache Groups and Cache Tables
reference any table in the cache group with a foreign key constraint. The primary key of the
root table is considered the primary key of the cache group. The orders table is a child table
of the customer root table. The order_item table is a child table of the orders child table.
TimesTen
Cache group customer_orders
customer (Root table)
cust_num region name address
orders Oracle
ord_num cust_num when_placed when_shipped database
44325 122 10/7/16 10/7/16
customer
65432 122 8/24/16 8/27/16
Child 76543 663 4/2/16 4/8/16
Tables Data for all customers
order_item orders
44325 TR3A 5
65432 FT094 1
76543 SD07 2
The table hierarchy in a multiple-table cache group can designate child tables to be parents
of other child tables. A child table cannot reference more than one parent table. However, a
parent table can be referenced by more than one child table.
Figure 4-3 shows an improper cache table hierarchy. Neither the customer nor the product
table references a table in the cache group with a foreign key constraint. This results in the
cache group having two root tables which is invalid.
4-5
Chapter 4
Cache Groups and Cache Tables
TimesTen
Cache group customer_orders
customer (Root table) Cannot Define
cust_num region name address Two Root Tables
122 West Jim Johnston 231 Main, Needles, CA 92363
product
orders
prod_name name price ship_weight description
ord_num cust_num when_placed when_shipped
SD07 1” brad $4.50 2 lbs brad
44325 122 10/7/16 10/7/16
TR3A .3” washer $1.94 5.4 lbs washer
65432 122 8/24/16 8/27/16
FT094 .4” washer $2.76 7.5 lbs washer
76543 663 4/2/16 4/8/16
FT133 .5” washer $1.50 2.5 lbs washer
order_item inventory
ord_num prod_num quantity prod_num warehouse quantity
Oracle
database
inventory
customer
product
orders
order_item
To resolve this problem and cache all the tables, create a cache group which contains
the customer, orders, and order_item tables, and a second cache group which
contains the product and the inventory tables as shown in Figure 4-4.
4-6
Chapter 4
Creating a Cache Group
TimesTen
Cache group customer_orders Cache group product_inventory
customer (Root table) product
cust_num region name address prod_name name price ship_weight description
122 West Jim Johnston 231 Main, Needles, CA 92363 SD07 1” brad $4.50 2 lbs brad
342 West Jane Stone 43 Cope, Palo Alto, CA 94302 TR3A .3” washer $1.94 5.4 lbs washer
663 Midwest Mary J. Warren 673 State, Madison, WI 53787 FT094 .4” washer $2.76 7.5 lbs washer
orders
inventory
ord_num cust_num when_placed when_shipped
prod_num warehouse quantity
44325 122 10/7/16 10/7/16
SD07 NewYork 2000
65432 122 8/24/16 8/27/16
TR3A London 10000
76543 663 4/2/16 4/8/16
FT094 London 30000
order_item
ord_num prod_num quantity
44325 SD07 1
44325 TR3A 5
65432 FT094 1
76543 SD07 2
Oracle
database
inventory
customer
product
orders
order_item
4-7
Chapter 4
Read-Only Cache Group
4-8
Chapter 4
Read-Only Cache Group
TimesTen
Application
database
TimesTen cache
Readonly
cache group
Oracle
database
If the TimesTen database is unavailable for whatever reason, you can still update the Oracle
Database tables that are cached in a read-only cache group. When the TimesTen database
returns to operation, updates that were committed on the cached Oracle Database tables
while the TimesTen database was unavailable are automatically refreshed to the TimesTen
cache tables.
Both TimesTen Classic and TimesTen Scaleout support read-only cache groups. TimesTen
Classic supports all read-only cache groups. TimesTen Scaleout only supports static read-
only cache groups with incremental autorefresh. See Using Cache Groups in TimesTen
Scaleout in the Oracle TimesTen In-Memory Database Scaleout User's Guide.
Note:
When TimesTen manages operations for read only cache groups, it connects to the
Oracle database using the Oracle cache administration user name and password.
For more details, see Set the Cache Administration User Name and Password.
The following are example definitions of the Oracle Database tables that are to be cached in
read-only cache groups. The Oracle Database tables are owned by the schema user sales.
The sales user must be granted the CREATE SESSION, CREATE TRIGGER, CREATE SEQUENCE,
CREATE TYPE, CREATE PROCEDURE, and CREATE TABLE privileges before it can create tables.
4-9
Chapter 4
Read-Only Cache Group
The companion Oracle Database cache administration user must be granted the
SELECT privilege on the sales.customer and sales.orders tables in order for the
TimesTen cache administration user to create a read-only cache group that caches
these tables, and for autorefresh operations to occur from the cached Oracle
Database tables to the TimesTen cache tables.
Use the CREATE READONLY CACHE GROUP statement to create a read-only cache group.
By default, all read-only cache groups are defined with incremental autorefresh
paused with the default interval value. Perform a LOAD CACHE GROUP statement for the
first load of the read-only cache group since the cache tables are empty. The
autorefresh state changes from PAUSED to ON after the LOAD CACHE GROUP statement
completes.
The cache tables in a read-only cache group cannot be updated directly. However, you
can set the passthrough level to 2 to allow committed update operations issued on a
TimesTen cache table to be passed through and processed on the cached Oracle
Database table, and then have the updates be automatically refreshed into the cache
table. See Setting a Passthrough Level.
The effects of a passed through statement on cache tables in a read-only cache group
do not occur in the transaction in which the update operation was issued. Instead, they
are seen after the passed through update operation has been committed on the Oracle
database and the next automatic refresh of the cache group has occurred. The
companion Oracle Database cache administration user must be granted the INSERT,
UPDATE and DELETE privileges on the Oracle Database tables that are cached in the
read-only cache group in order for the passed through update operations to be
processed on the cached Oracle Database tables.
4-10
Chapter 4
Read-Only Cache Group
If you manually created the Oracle Database objects used to enforce the predefined
behaviors of a cache group with autorefresh as described in The initCacheAdminSchema.sql
Script, you need to set the autorefresh state to OFF when creating the cache group.
Then you need to run the ttIsql utility's cachesqlget command to generate a SQL*Plus
script used to create a log table and a trigger in the Oracle database for each Oracle
Database table that is cached in the read-only cache group. See Manually Creating Oracle
Database Objects for Cache Groups With Autorefresh for how to create these objects.
4-11
Chapter 4
Asynchronous WriteThrough (AWT) Cache Group
Note:
You should avoid running DML statements on Oracle Database tables
cached in an AWT cache group. This can result in an error condition. See
Restrictions With AWT Cache Groups.
TimesTen
Application database
TimesTen cache
AWT
cache group
Automatically
propagate Load upon
updates request
Oracle
database
Since an AWT cache group propagates data from the TimesTen database to the
Oracle database, any data modified by the user in the cached tables on the Oracle
database is not automatically uploaded from the Oracle database to the TimesTen
4-12
Chapter 4
Asynchronous WriteThrough (AWT) Cache Group
database. In this case, you must explicitly unload and then reload the AWT cache groups on
TimesTen.
The transaction commit on the TimesTen database occurs asynchronously from the commit
on the Oracle database. This enables an application to continue issuing transactions on the
TimesTen database without waiting for the Oracle Database transaction to complete.
However, your application cannot ensure when the transactions are completed on the Oracle
database.
Processing of the UNLOAD CACHE GROUP statement for an AWT cache group waits until
updates on the rows have been propagated to the Oracle database.
You can update cache tables in an AWT cache group even if the Oracle database is
unavailable. When the Oracle database returns to operation, updates that were committed on
the cache tables while the Oracle database was unavailable are automatically propagated to
the cached Oracle Database tables.
Note:
When TimesTen manages operations for AWT cache groups, it connects to the
Oracle database using the Oracle cache administration user name and password
set with the ttCacheUidPwdSet built-in procedure. For more details on
ttCacheUidPwdSet, see Set the Cache Administration User Name and Password.
The following is an example of a definition of the Oracle Database table that is to be cached
in an AWT cache group. The Oracle Database table is owned by the schema user sales. The
sales user must be granted the CREATE SESSION, CREATE TRIGGER, CREATE SEQUENCE, CREATE
TYPE, CREATE PROCEDURE, and CREATE TABLE privileges before it can create tables.
CREATE TABLE customer
(cust_num NUMBER(6) NOT NULL PRIMARY KEY,
region VARCHAR2(10),
name VARCHAR2(50),
address VARCHAR2(100));
The companion Oracle cache administration user must be granted the SELECT privilege on the
sales.customer table in order for the TimesTen cache administration user to create an AWT
cache group that caches this table. The Oracle cache administration user must be granted
the INSERT, UPDATE and DELETE Oracle Database privileges on the sales.customer table for
asynchronous writethrough operations to be applied to the Oracle Database.
Use the CREATE ASYNCHRONOUS WRITETHROUGH CACHE GROUP statement to create an AWT
cache group.
The following statement creates an AWT cache group new_customers that caches the
sales.customer table:
CREATE ASYNCHRONOUS WRITETHROUGH CACHE GROUP new_customers
FROM sales.customer
(cust_num NUMBER(6) NOT NULL,
region VARCHAR2(10),
name VARCHAR2(50),
address VARCHAR2(100),
PRIMARY KEY(cust_num));
4-13
Chapter 4
Asynchronous WriteThrough (AWT) Cache Group
The following sections describe configuration, behavior, and management for AWT
cache groups:
• Starting and Stopping the Replication Agent
• Setting a Replication Agent Start Policy
• Monitoring Propagation of Transactions to the Oracle Database
• Disabling Propagation of Committed Changes
• Configuring Parallel Propagation to the Oracle Database
• What an AWT Cache Group Does and Does Not Guarantee
• Restrictions With AWT Cache Groups
• Reporting Oracle Database Permanent Errors for AWT Cache Groups
It can also be started from a command line by running a ttAdmin -repStart utility
command as a TimesTen external user with the CACHE_MANAGER privilege:
% ttAdmin -repStart cache1
The replication agent does not start unless there is at least one AWT cache group or
replication scheme in the TimesTen database.
If the replication agent is running, it must be stopped before you can issue another
CREATE ASYNCHRONOUS WRITETHROUGH CACHE GROUP statement or a DROP CACHE GROUP
statement on an AWT cache group.
You can stop the replication agent by calling the ttRepStop built-in procedure as the
cache administration user:
Command> call ttRepStop;
You can also stop the replication agent from a command line with the ttAdmin -
repStop utility command as a TimesTen external user with the CACHE_MANAGER
privilege:
% ttAdmin -repStop cache1
4-14
Chapter 4
Asynchronous WriteThrough (AWT) Cache Group
The start policy can be set to always so that the replication agent starts automatically when
the TimesTen main daemon process starts. With the always start policy, the replication agent
cannot be stopped when the main daemon is running unless the start policy is changed to
either manual or norestart and then a manual stop is issued by calling the ttRepStop built-in
procedure or running a ttAdmin -repStop utility command.
With the manual and always start policies, the replication agent automatically restarts after a
failure such as a database invalidation.
The start policy can be set to norestart which means the replication agent must be started
manually by calling the ttRepStart built-in procedure or running a ttAdmin -repStart utility
command, and stopped manually by calling the ttRepStop built-in procedure or running a
ttAdmin -repStop utility command.
With the norestart start policy, the replication agent does not automatically restart after a
failure such as a database invalidation. You must restart the replication agent manually by
calling the ttRepStart built-in procedure or running a ttAdmin -repStart utility command.
2. Set the replication agent start policy by calling the ttRepPolicySet built-in procedure as
the TimesTen cache administration user:
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> call ttRepPolicySet('manual');
Command> exit
Alternately, set the replication agent start policy from a command line by running a
ttAdmin -repPolicy utility command as a TimesTen external user with the ADMIN
privilege:
% ttAdmin -repPolicy always cache1
4-15
Chapter 4
Asynchronous WriteThrough (AWT) Cache Group
and transaction log files until the replication agent confirms they have been fully
processed by the Oracle database.
You can monitor the propagation for these transactions with the ttLogholds built-in
procedure.
When you call the ttLogHolds built-in procedure, the description field contains
_ORACLE to identify the transaction log hold for the AWT cache group propagation.
Command> call ttLogHolds();
< 0, 18958336, Checkpoint , cache1.ds0 >
< 0, 19048448, Checkpoint , cache1.ds1 >
< 0, 19050904, Replication , ADC6160529:_ORACLE >
3 rows found.
See the Show Replicated Log Records section in the Oracle TimesTen In-Memory
Database Replication Guide.
You can also improve performance by configuring parallel propagation to the Oracle
Database. See Improving AWT Throughput With Parallel Propagation to the Oracle
Database.
After the flag is set to zero, the effects of running any DML statements are never
propagated to the back-end Oracle database. Thus, these updates exist only on the
TimesTen database. You can then re-enable propagation by resetting the flag to one
with the ttCachePropagateFlagSet built-in procedure. After the flag is set back to one,
propagation of all committed changes to the Oracle database resumes. The
propagation flag automatically resets to one after the transaction is committed or rolled
back. See ttCachePropagateFlagSet in the Oracle TimesTen In-Memory Database
Reference.
4-16
Chapter 4
Asynchronous WriteThrough (AWT) Cache Group
• If the replication agent is not running or loses its connection to the Oracle database,
automatic propagation of committed changes on the TimesTen cache tables to the
cached Oracle Database tables resumes after the agent restarts or reconnects to the
Oracle database.
• Transactions are committed in the Oracle database in the same order they were
committed in the TimesTen database.
An AWT cache group cannot guarantee that:
• All transactions committed successfully in the TimesTen database are successfully
propagated to and committed in the Oracle database. Execution errors on the Oracle
database cause the transaction in the Oracle database to be rolled back. For example,
an update on the Oracle database may fail because of a unique constraint violation.
Transactions that contain execution errors are not retried.
Execution errors are considered permanent errors and are reported to the
TimesTenDatabaseFileName.awterrs file that resides in the same directory as the
TimesTen database's checkpoint files. See Reporting Oracle Database Permanent Errors
for AWT Cache Groups.
• The absolute order of Oracle Database updates is preserved because TimesTen does not
resolve update conflicts. The following are some examples:
– In two separate TimesTen databases (DB1 and DB2), different AWT cache groups
cache the same Oracle Database table. An update is committed on the cache table in
DB1. An update is then committed on the cache table in DB2. The two cache tables
reside in different TimesTen databases and cache the same Oracle Database table.
Because the writethrough operations are asynchronous, the update from DB2 may get
propagated to the Oracle database before the update from DB1, resulting in the
update from DB1 overwriting the update from DB2.
– An update is committed on a cache table in an AWT cache group. The same update
is committed on the cached Oracle Database table using a passthrough operation.
The cache table update, which is automatically and asynchronously propagated to
the Oracle database, may overwrite the passed through update that was processed
directly on the cached Oracle Database table depending on when the propagated
update and the passed through update is processed on the Oracle database. For this
and other potential error conditions, TimesTen recommends that you do not run DML
statements directly against Oracle Database tables cached in an AWT cache group.
For more information, see Restrictions With AWT Cache Groups.
4-17
Chapter 4
Asynchronous WriteThrough (AWT) Cache Group
4-18
Chapter 4
Asynchronous WriteThrough (AWT) Cache Group
For example, an update on the Oracle database may fail because of a unique constraint
violation. Transactions that contain permanent errors are not retried.
Permanent errors are always reported to the TimesTenDatabaseFileName.awterrs text file
that resides in the same directory as the TimesTen database checkpoint files. See Oracle
Database Errors Reported by TimesTen for AWT in the Oracle TimesTen In-Memory
Database Monitoring and Troubleshooting Guide for information about the contents of this
file.
You can configure TimesTen to report these errors in both ASCII and XML formats with the
ttCacheConfig built-in procedure.
Note:
Do not pass in any values to the tblOwner and tblName parameters for
ttCacheConfig as they are not applicable to setting the format for the errors file.
Note:
Before calling ttCacheConfig to direct permanent errors to the XML file, you must
first stop the replication agent. Then, restart the replication agent after the built-in
procedure completes.
See ttCacheConfig in the Oracle TimesTen In-Memory Database Reference.
When you configure error reporting to be reported in XML format, the following two files are
generated when Oracle Database permanent errors occur:
• TimesTenDatabaseFileName.awterrs.xml contains the Oracle Database permanent error
messages in XML format.
• TimesTenDatabaseFileName.awterrs.dtd is the file that contains the XML Document
Type Definition (DTD), which is used when parsing the
TimesTenDatabaseFileName.awterrs.xml file.
The XML DTD, which is based on the XML 1.0 specification, is a set of markup
declarations that describes the elements and structure of a valid XML file containing a log
of errors. The XML file is encoded using UTF-8. The following are the elements for the
XML format.
4-19
Chapter 4
Synchronous WriteThrough (SWT) Cache Group
Note:
For more information on reading and understanding XML Document
Type Definitions, see http://www.w3.org/TR/REC-xml/.
Note:
You should avoid running DML statements on Oracle Database tables
cached in an SWT cache group. This can result in an error condition. See
Restrictions With SWT Cache Groups.
4-20
Chapter 4
Synchronous WriteThrough (SWT) Cache Group
TimesTen
Application
database
TimesTen cache
Synchronous
writethrough
cache group
Automatically
propagate Load upon
updates creation
Oracle
database
The transaction commit on the TimesTen database occurs synchronously with the commit on
the Oracle database. When an application commits a transaction in the TimesTen database,
the transaction is processed in the Oracle database before it is processed in TimesTen. The
application is blocked until the transaction has completed in both the Oracle and TimesTen
databases.
If the transaction fails to commit in the Oracle database, the application must roll back the
transaction in TimesTen. If the Oracle Database transaction commits successfully but the
TimesTen transaction fails to commit, the cache tables in the SWT cache group are no longer
synchronized with the cached Oracle Database tables.
Note:
The behavior and error conditions for how commit occurs on both the TimesTen and
Oracle databases when committing propagated updates is the same commit
process on a user managed cache group with the PROPAGATE cache attribute that is
described in PROPAGATE Cache Table Attribute.
To manually resynchronize the cache tables with the cached Oracle Database tables, call the
ttCachePropagateFlagSet built-in procedure to disable update propagation, and then reissue
the transaction in the TimesTen database after correcting the problem that caused the
transaction commit to fail in TimesTen. Then, call the ttCachePropagateFlagSet built-in
4-21
Chapter 4
Synchronous WriteThrough (SWT) Cache Group
procedure to re-enable update propagation. You can also resynchronize the cache
tables with the cached Oracle Database tables by reloading the accompanying cache
groups.
The following is an example definition of the Oracle Database table that is to be
cached in an example SWT cache group. The Oracle Database table is owned by the
schema user sales. The sales user must be granted the CREATE SESSION, CREATE
TRIGGER, CREATE SEQUENCE, CREATE TYPE, CREATE PROCEDURE, and CREATE TABLE
privileges before it can create tables.
CREATE TABLE product
(prod_num VARCHAR2(6) NOT NULL PRIMARY KEY,
name VARCHAR2(30),
price NUMBER(8,2),
ship_weight NUMBER(4,1));
The companion Oracle cache administration user must be granted the SELECT privilege
on the sales.product table in order for the TimesTen cache administration user to
create an SWT cache group that caches this table. The Oracle cache administration
user must also be granted the INSERT, UPDATE, and DELETE privileges on the
sales.product table for synchronous writethrough operations to occur from the
TimesTen cache table to the cached Oracle Database table.
Use the CREATE SYNCHRONOUS WRITETHROUGH CACHE GROUP statement to create an
SWT cache group.
The following statement creates a synchronous writethrough cache group
top_products that caches the sales.product table:
CREATE SYNCHRONOUS WRITETHROUGH CACHE GROUP top_products
FROM sales.product
(prod_num VARCHAR2(6) NOT NULL,
name VARCHAR2(30),
price NUMBER(8,2),
ship_weight NUMBER(4,1),
PRIMARY KEY(prod_num));
When TimesTen manages operations for SWT cache groups, it connects to the Oracle
database using the current user's credentials as the user name and the OraclePwd
connection attribute as the Oracle password. TimesTen does not connect to the Oracle
database with the Oracle cache administration user name and password set with the
ttCacheUidPwdSet built-in procedure when managing SWT cache group operations.
See Set the Cache Administration User Name and Password.
4-22
Chapter 4
Hybrid Cache Group
4-23
Chapter 4
Hybrid Cache Group
1. The customer root table exists only on the TimesTen database and contains only a
primary key. You do not create the root table in the Oracle database as it is
created by TimesTen when you specify the root table in the CREATE DYNAMIC
HYBRID READONLY CACHE GROUP statement.
2. Customers can have more than one order and each order can go to a different
location. To track the order status for each customer location, the locations and
orders tables are created on the Oracle database and are children of the customer
table.
With the customer_id as part of the composite key for both the locations and
orders tables, you can print out the status of all orders for each customer location.
In addition, the invoices table (as a child of the orders table) can be queried to
determine if the order has been paid.
CREATE TABLE locations
(customer_id NUMBER(6),
location_id NUMBER(6),
name VARCHAR2(255) NOT NULL,
street CHAR(30) NOT NULL,
city CHAR(20) NOT NULL,
state CHAR(2) NOT NULL,
zipcode CHAR(10) NOT NULL,
PRIMARY KEY (customer_id, location_id));
3. Use the CREATE DYNAMIC HYBRID READONLY CACHE GROUP statement to create the
customer root table on TimesTen and a dynamic hybrid read-only cache group
called customer_orders, which caches the Oracle database tables: locations,
orders, and invoices (child tables). Note that the locations and orders cache
tables reference the primary key of the customer root table that exists on the
TimesTen database.
4-24
Chapter 4
Hybrid Cache Group
Note:
See CREATE CACHE GROUP in the Oracle TimesTen In-Memory Database
SQL Reference.
locations
(customer_id NUMBER(6),
location_id NUMBER(6),
name VARCHAR2(255) NOT NULL,
street CHAR(30) NOT NULL,
city CHAR(20) NOT NULL,
state CHAR(2) NOT NULL,
zipcode CHAR(10) NOT NULL,
PRIMARY KEY (customer_id, location_id),
FOREIGN KEY (customer_id) REFERENCES customer(customer_id)),
orders
(order_id NUMBER,
location_id NUMBER(6),
customer_id NUMBER(6),
when_placed DATE NOT NULL,
status NUMBER(2) NOT NULL,
PRIMARY KEY (order_id, location_id, customer_id),
FOREIGN KEY (customer_id) REFERENCES customer(customer_id)),
invoices
(invoice_id NUMBER,
order_id NUMBER,
total NUMBER,
paid NUMBER,
PRIMARY KEY (invoice_id),
FOREIGN KEY (order_id) REFERENCES order(order_id));
4-25
Chapter 4
Hybrid Cache Group
And the following query triggers a dynamic load since the locations table equates its
foreign key with the orders table foreign key.
SELECT * FROM orders, locations
WHERE orders.customer_id=:id and locations.customer_id=:id;
Example 4-3 Dynamic Load Condition Using a First Level Child Table and a
Derived Table
The following query triggers a dynamic load since two first level child tables (orders
and locations) specify the same dynamic load condition. The locations table
equates its foreign key with the dynamically loaded foreign key from the orders table.
The derived table is temporarily named cust as that name is provided directly after the
derived table specification.
4-26
Chapter 4
Hybrid Cache Group
SELECT * FROM
(SELECT customer_id,order_id FROM orders
WHERE customer_id=:id and ROWNUM <= 5) cust, invoices, locations
WHERE
invoices.order_id = cust.order_id and locations.customer_id=cust.customer_id;
Example 4-4 Dynamic Load Condition Using a First Level Child Table and Grandchild
Table
The following query example triggers a dynamic load since the dynamic load condition is on a
derived table that includes the orders table (a first level child table of the customer_orders
hybrid cache group). It also includes the grandchild table invoices that is included in a
foreign key join condition with the derived table cust.
Temporarily, the derived table name is orders and is treated as a parent table.
SELECT * FROM
(SELECT customer_id,order_id FROM orders
WHERE customer_id=? and ROWNUM <= 5) cust, invoices
WHERE invoices.order_id = cust.order_id;
Example 4-5 Dynamic Load Using Grandchild Table Joined With Derived Table
The following query triggers a dynamic load because the invoices table (as a grandchild
table) is joined with the derived table cust through a foreign key join:
SELECT * FROM
(SELECT customer_id,order_id FROM orders
WHERE customer_id=? and ROWNUM <= 5) cust, invoices
WHERE invoices.order_id = cust.order_id;
Example 4-6 No Dynamic Load Example With First Level Child Table
The following query does not trigger a dynamic load because the first level child locations
table specifies a different dynamic load condition than the derived table (cust) load condition:
SELECT * FROM
(SELECT customer_id,order_id FROM orders
WHERE customer_id=:id and ROWNUM <= 5) cust, invoices, locations
WHERE invoices.order_id = cust.order_id and locations.customer_id=:id2;
4-27
Chapter 4
User Managed Cache Group
Note:
When TimesTen manages operations for user managed cache groups, it
connects to the Oracle database using the current user's credentials as the
user name and the OraclePwd connection attribute as the Oracle password.
TimesTen does not connect to the Oracle database with the cache
administration user name and password set with the ttCacheUidPwdSet built-
in procedure for user managed cache group operations. See Set the Cache
Administration User Name and Password.
4-28
Chapter 4
User Managed Cache Group
• You can specify the READONLY Cache Table Attribute on individual cache tables in a
user managed cache group to define read-only behavior where the data is refreshed on
TimesTen from the Oracle database at the table level.
• You can specify the PROPAGATE cache table attribute on individual cache tables in a user
managed cache group to define synchronous writethrough behavior at the table level.
The PROPAGATE Cache Table Attribute specifies that committed changes on the cache
table are automatically and synchronously propagated to the cached Oracle Database
table.
• You can define a user managed cache group to automatically refresh and propagate
committed changes between the Oracle and TimesTen databases by using the
AUTOREFRESH cache group attribute and the PROPAGATE cache table attribute. Using both
attributes enables bidirectional transmit, so that committed changes on the TimesTen
cache tables or the cached Oracle Database tables are propagated or refreshed to each
other.
See Automatically Refreshing a Cache Group for more information about defining an
autorefresh mode, interval, and state.
• You can use the LOAD CACHE GROUP, REFRESH CACHE GROUP, and FLUSH CACHE GROUP
statements to manually control the transmit of committed changes between the Oracle
and TimesTen databases.
See Manually Loading and Refreshing a Cache Group for more information about the
LOAD CACHE GROUP and REFRESH CACHE GROUP statements. See Flushing a User Managed
Cache Group for more information about the FLUSH CACHE GROUP statement.
• You can cache Oracle Database materialized views in a user managed cache group that
does not use either the PROPAGATE or AUTOREFRESH cache group attributes. The cache
group must be manually loaded and flushed. You cannot cache Oracle Database views.
The following sections provide more information about user managed cache groups:
• READONLY Cache Table Attribute
• PROPAGATE Cache Table Attribute
• Examples of User Managed Cache Groups
• If the cache group uses the AUTOREFRESH cache group attribute, the READONLY cache table
attribute must be specified on all or none of its cache tables.
See Automatically Refreshing a Cache Group for more information about using the
AUTOREFRESH cache group attribute.
4-29
Chapter 4
User Managed Cache Group
• You cannot use both the READONLY and PROPAGATE cache table attributes on the
same cache table.
See PROPAGATE Cache Table Attribute for more information about using the
PROPAGATE cache table attribute.
• A FLUSH CACHE GROUP statement cannot be issued on the cache group unless one
or more of its cache tables use neither the READONLY nor the PROPAGATE cache
table attribute.
See Flushing a User Managed Cache Group for more information about the FLUSH
CACHE GROUP statement.
• After the READONLY cache table attribute has been specified on a cache table, you
cannot change this attribute unless you drop the cache group and re-create it.
Note:
If the TimesTen database or its daemon fails unexpectedly, the results of the
transaction on either the TimesTen or Oracle databases are not guaranteed.
Since the operations in the transaction are applied to tables in both the TimesTen and
Oracle databases, the process for committing is as follows:
1. After the operations are propagated to the Oracle database, the commit is first
attempted in the Oracle database.
• If an error occurs when applying the operations on the tables in the Oracle
database, then all operations are rolled back on the tables on the Oracle
database. If the commit fails in the Oracle database, the commit is not
attempted in the TimesTen database and the application must roll back the
TimesTen transaction. If the user tries to run another statement, an error
displays informing them of the need for a roll back. As a result, the Oracle
database never misses updates committed in TimesTen.
2. If the commit succeeds in the Oracle database, the commit is attempted in the
TimesTen database.
4-30
Chapter 4
User Managed Cache Group
• If the transaction successfully commits on the Oracle database, the user's transaction
is committed on TimesTen (indicated by the commit log record in the transaction log)
and notifies the application. If the application ends abruptly before TimesTen informs
it of the success of the local commit, TimesTen is still able to finalize the transaction
commit on TimesTen based on what is saved in the transaction log.
• If the transaction successfully commits on the Oracle database and a failure occurs
before returning the status of the commit on TimesTen, then no record of the
successful commit is written into the transaction log and the transaction is rolled
back.
• If the commit fails in TimesTen, an error message is returned from TimesTen
indicating the cause of the failure. You then need to manually resynchronize the
cache tables with the Oracle Database tables.
Note:
See Synchronous WriteThrough (SWT) Cache Group for information on
how to re-synchronize the cache tables with the Oracle Database tables.
You can disable propagation of committed changes on the TimesTen cached tables to the
Oracle database with the ttCachePropagateFlagSet built-in procedure. This built-in
procedure can enable or disable automatic propagation so that committed changes on a
cache table on TimesTen for the current transaction are never propagated to the cached
Oracle Database table. You can then re-enable propagation for DML statements by resetting
the flag to one with the ttCachePropagateFlagSet built-in procedure. After the flag is set
back to one, propagation of committed changes to the Oracle database resumes. The
propagation flag automatically resets to one after the transaction is committed or rolled back.
See ttCachePropagateFlagSet in the Oracle TimesTen In-Memory Database Reference.
The following restrictions apply when using the PROPAGATE cache table attribute:
• If the cache group uses the AUTOREFRESH cache group attribute, the PROPAGATE cache
table attribute must be specified on all or none of its cache tables.
See Automatically Refreshing a Cache Group for more information about using the
AUTOREFRESH cache group attribute.
• If the cache group uses the AUTOREFRESH cache group attribute, the NOT PROPAGATE cache
table attribute cannot be explicitly specified on any of its cache tables.
• You cannot use both the PROPAGATE and READONLY cache table attributes on the same
cache table.
See READONLY Cache Table Attribute for more information about using the READONLY
cache table attribute.
• A FLUSH CACHE GROUP statement cannot be issued on the cache group unless one or
more of its cache tables use neither the PROPAGATE nor the READONLY cache table
attribute.
See Flushing a User Managed Cache Group for more information about the FLUSH CACHE
GROUP statement.
• After the PROPAGATE cache table attribute has been specified on a cache table, you
cannot change this attribute unless you drop the cache group and re-create it.
4-31
Chapter 4
User Managed Cache Group
• The PROPAGATE cache table attribute cannot be used when caching Oracle
Database materialized views.
• TimesTen does not perform a conflict check to prevent a propagate operation from
overwriting data that was updated directly on a cached Oracle Database table.
Therefore, updates should only be performed directly on the TimesTen cache
tables or the cached Oracle Database tables, but not both.
Use the CREATE USERMANAGED CACHE GROUP statement to create a user managed
cache group.
The following statement creates a user managed cache group
update_anywhere_customers that caches the sales.active_customer table as shown
in Figure 4-8:
CREATE USERMANAGED CACHE GROUP update_anywhere_customers
AUTOREFRESH MODE INCREMENTAL INTERVAL 30 SECONDS
FROM sales.active_customer
(custid NUMBER(6) NOT NULL,
name VARCHAR2(50),
addr VARCHAR2(100),
zip VARCHAR2(12),
PRIMARY KEY(custid),
PROPAGATE);
4-32
Chapter 4
User Managed Cache Group
TimesTen
User managed cache group update_anywhere_customers
active_customer
custid name address zip
Oracle
database
active_customer
In this example, all columns except region from the sales.active_customer table are
cached in TimesTen. Since this is defined with the PROPAGATE cache table attribute, updates
committed on the sales.active_customer cache table on TimesTen are transmitted to the
sales.active_customer cached Oracle Database table. Since the user managed cache table
is also defined with the AUTOREFRESH cache attribute, any committed changes on the
sales.active_customer Oracle Database table are transmitted to the
update_anywhere_customers cached table.
The companion Oracle cache administration user must be granted the SELECT privilege on the
sales.active_customer table in order for the TimesTen cache administration user to create a
user managed cache group that caches this table, and for autorefresh operations to occur
from the cached Oracle Database table to the TimesTen cache table. The companion Oracle
cache administration user must also be granted the INSERT, UPDATE and DELETE privileges on
the sales.active_customer table for synchronous writethrough operations to occur from the
TimesTen cache table to the cached Oracle Database table.
In this example, the AUTOREFRESH cache group attribute specifies that committed changes on
the sales.active_customer cached Oracle Database table are automatically refreshed to the
TimesTen sales.active_customer cache table every 30 seconds.
If you manually created the Oracle Database objects used to enforce the predefined
behaviors of a user managed cache group that uses the AUTOREFRESH MODE INCREMENTAL
4-33
Chapter 4
User Managed Cache Group
Then you need to run the ttIsql utility's cachesqlget command to generate a
SQL*Plus script used to create a log table and a trigger in the Oracle database for
each Oracle Database table that is cached in the user managed cache group.
See Manually Creating Oracle Database Objects for Cache Groups With Autorefresh.
The following statement creates a multiple-table user managed cache group
western_customers that caches the sales.active_customer, sales.ordertab,
sales.cust_interests, and sales.orderdetails tables as shown in Figure 4-9:
CREATE USERMANAGED CACHE GROUP western_customers
FROM sales.active_customer
(custid NUMBER(6) NOT NULL,
name VARCHAR2(50),
addr VARCHAR2(100),
zip VARCHAR2(12),
region VARCHAR2(12),
PRIMARY KEY(custid),
PROPAGATE)
WHERE (sales.active_customer.region = 'West'),
sales.ordertab
(orderid NUMBER(10) NOT NULL,
custid NUMBER(6) NOT NULL,
PRIMARY KEY(orderid),
FOREIGN KEY(custid) REFERENCES sales.active_customer(custid),
PROPAGATE),
sales.cust_interests
(custid NUMBER(6) NOT NULL,
interest VARCHAR2(10) NOT NULL,
PRIMARY KEY(custid, interest),
FOREIGN KEY(custid) REFERENCES sales.active_customer(custid),
READONLY),
sales.orderdetails
(orderid NUMBER(10) NOT NULL,
itemid NUMBER(8) NOT NULL,
quantity NUMBER(4) NOT NULL,
PRIMARY KEY(orderid, itemid),
FOREIGN KEY(orderid) REFERENCES sales.ordertab(orderid))
WHERE (sales.orderdetails.quantity >= 5);
4-34
Chapter 4
User Managed Cache Group
TimesTen
User managed cache group western_customers
active_customer (Root table)
custid name address zip region
ordertab cust_interests
orderid custid custid interests
orderdetails
orderid itemid quantity
Oracle
database
active_customer
cust_interests
ordertab
order_details
Only customers in the West region who ordered at least 5 of the same item are cached.
The companion Oracle cache administration user must be granted the SELECT privilege on the
sales.active_customer, sales.ordertab, sales.cust_interests, and sales.orderdetails
tables in order for the TimesTen cache administration user to create a user managed cache
group that caches all of these tables. The companion Oracle cache administration user must
also be granted the INSERT, UPDATE and DELETE privileges on the sales.active_customer
and sales.ordertab tables for synchronous writethrough operations to occur from these
TimesTen cache tables to the cached Oracle Database tables.
Each cache table in the western_customers cache group contains a primary key. Each child
table references a parent table with a foreign key constraint. The sales.active_customer
root table and the sales.orderdetails child table each contain a WHERE clause to restrict the
rows to be cached. The sales.active_customer root table and the sales.ordertab child
table both use the PROPAGATE Cache Table Attribute so that committed changes on these
4-35
Chapter 4
Using a WHERE Clause
cache tables are automatically propagated to the cached Oracle Database tables. The
sales.cust_interests child table uses the READONLY Cache Table Attribute so that
it cannot be updated directly.
The following restrictions apply to WHERE clauses used in cache table definitions and
cache group operations:
• WHERE clauses can only be specified in the cache table definitions of a CREATE
CACHE GROUP statement for read-only and user managed cache groups.
• A WHERE clause can be specified in a LOAD CACHE GROUP statement except on a
static cache group with autorefresh.
See Manually Loading and Refreshing a Cache Group for more information about
the LOAD CACHE GROUP.
• A WHERE clause can be specified in a REFRESH CACHE GROUP statement except on a
cache group with autorefresh.
See Manually Loading and Refreshing a Cache Group for more information about
the REFRESH CACHE GROUP statement.
• A WHERE clause can be specified in a FLUSH CACHE GROUP statement on a user
managed cache group that allows committed changes on the TimesTen cache
tables to be flushed to the cached Oracle Database tables.
See Flushing a User Managed Cache Group for more information about the FLUSH
CACHE GROUP statement.
• WHERE clauses in a CREATE CACHE GROUP statement cannot contain a subquery.
Therefore, each WHERE clause cannot reference any table other than the one in its
cache table definition. However, a WHERE clause in a LOAD CACHE GROUP, UNLOAD
CACHE GROUP, REFRESH CACHE GROUP or FLUSH CACHE GROUP statement may contain
a subquery.
• A WHERE clause in a LOAD CACHE GROUP, REFRESH CACHE GROUP or FLUSH CACHE
GROUP statement can reference only the root table of the cache group, unless the
WHERE clause contains a subquery.
• WHERE clauses in the cache table definitions are only enforced when the cache
group is manually loaded or refreshed, or the cache tables are dynamically loaded.
If a cache table is updatable, you can insert or update a row such that the WHERE
clause in the cache table definition for that row is not satisfied.
4-36
Chapter 4
Using a WHERE Clause
• All tables and columns referenced in WHERE clauses when creating, loading, refreshing,
unloading or flushing the cache group must be fully qualified. For example:
owner.table_name and owner.table_name.column_name
The following statement is not valid because the WHERE clause in the child table's definition
references its parent table:
CREATE READONLY CACHE GROUP customer_orders
FROM sales.customer
(cust_num NUMBER(6) NOT NULL,
region VARCHAR2(10),
name VARCHAR2(50),
address VARCHAR2(100),
PRIMARY KEY(cust_num)),
sales.orders
(ord_num NUMBER(10) NOT NULL,
cust_num NUMBER(6) NOT NULL,
when_placed DATE NOT NULL,
when_shipped DATE NOT NULL,
4-37
Chapter 4
Using a WHERE Clause
PRIMARY KEY(ord_num),
FOREIGN KEY(cust_num) REFERENCES sales.customer(cust_num))
WHERE (sales.customer.cust_num < 100);
Similarly, the following statement is not valid because the WHERE clause in the parent
table's definition references its child table:
CREATE READONLY CACHE GROUP customer_orders
FROM sales.customer
(cust_num NUMBER(6) NOT NULL,
region VARCHAR2(10),
name VARCHAR2(50),
address VARCHAR2(100),
PRIMARY KEY(cust_num))
WHERE (sales.orders.cust_num < 100),
sales.orders
(ord_num NUMBER(10) NOT NULL,
cust_num NUMBER(6) NOT NULL,
when_placed DATE NOT NULL,
when_shipped DATE NOT NULL,
PRIMARY KEY(ord_num),
FOREIGN KEY(cust_num) REFERENCES sales.customer(cust_num));
After creating the function, create a public synonym for the function. Then grant the
EXECUTE privilege on the function to PUBLIC.
Then in the TimesTen database, for example, you can create a cache group with a
WHERE clause that references the Oracle Database public synonym that was created for
the function:
CREATE READONLY CACHE GROUP top_customer
FROM sales.customer
(cust_num NUMBER(6) NOT NULL,
region VARCHAR2(10),
name VARCHAR2(50),
address VARCHAR2(100),
PRIMARY KEY(cust_num))
WHERE name = retname(100);
For cache group types that allow a WHERE clause on a LOAD CACHE GROUP or REFRESH
CACHE GROUP statement, you can invoke the function indirectly by referencing the
4-38
Chapter 4
Specifying Automatic Refresh With the AUTOREFRESH Cache Group Attribute
public synonym that was created for the function. For example, you can use the following
LOAD CACHE GROUP statement to load the AWT cache group new_customers:
LOAD CACHE GROUP new_customers WHERE name = retname(101) COMMIT EVERY 0 ROWS;
AUTOREFRESH specifies that committed changes on cached Oracle Database tables are
automatically refreshed to the cache tables on TimesTen. Autorefresh is defined by default on
read-only cache groups. See Automatically Refreshing a Cache Group.
Note:
Only TimesTen Classic supports the DYNAMIC keyword in its cache groups.
See CREATE CACHE GROUP in the Oracle TimesTen In-Memory Database SQL Reference.
4-39
Chapter 4
ON DELETE CASCADE Cache Table Attribute
All paths from a parent table to a child table must be either "delete" paths or "do not
delete" paths. There cannot be some "delete" paths and some "do not delete" paths
from a parent table to a child table. Specify the ON DELETE CASCADE cache table
attribute for child tables on a "delete" path.
The following restrictions apply when using the ON DELETE CASCADE cache table
attribute:
• For AWT and SWT cache groups, and for TimesTen cache tables in user managed
cache groups that use the PROPAGATE cache table attribute, foreign keys in cache
tables that use the ON DELETE CASCADE cache table attribute must be a proper
subset of the foreign keys in the cached Oracle Database tables that use the ON
DELETE CASCADE attribute. ON DELETE CASCADE actions on the cached Oracle
Database tables are applied to the cache tables on TimesTen as individual
deletes. ON DELETE CASCADE actions on the cache tables are applied to the cached
Oracle Database tables as a cascaded operation.
• Matching of foreign keys between the cache tables on TimesTen and the cached
Oracle Database tables is enforced only when the cache group is being created. A
cascade delete operation may not work if the foreign keys on the cached Oracle
Database tables are altered after the cache group is created.
See CREATE CACHE GROUP in the Oracle TimesTen In-Memory Database SQL
Reference.
4-40
Chapter 4
Caching Oracle Database LOB Data
The private synonym can reference a public or private synonym, but it must eventually
reference a table because it is the table that is actually being cached.
The table that is directly or indirectly referenced by the cached synonym can be owned by a
user other than the Oracle Database user with the same name as the owner of the cache
group that caches the synonym. The table must reside in the same Oracle database as the
synonym. The cached synonym itself must be owned by the Oracle Database user with the
same name as the owner of the cache group that caches the synonym.
2. Insert values into the Oracle Database table. The values are implicitly converted to
TimesTen VARCHAR2, VARBINARY, OR NVARCHAR2 data types.
INSERT INTO t VALUES (1
, RPAD('abcdefg8', 2048, 'abcdefg8')
, HEXTORAW(RPAD('123456789ABCDEF8', 4000, '123456789ABCDEF8'))
, RPAD('abcdefg8', 2048, 'abcdefg8')
);
1 row inserted.
3. Create a dynamic AWT cache group and start the replication agent.
CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH CACHE GROUP cg1
FROM t
(i INT NOT NULL PRIMARY KEY
, c VARCHAR2(4194303)
, b VARBINARY(4194303)
, nc NVARCHAR2(2097152));
CALL ttrepstart;
I: 1
C: abcdefg8abcdefg8abcdefg8...
B: 123456789ABCDEF8123456789...
NC: abcdefg8abcdefg8abcdefg8...
1 row found.
4-41
Chapter 4
Implementing Aging in a Cache Group for TimesTen Classic
4-42
Chapter 4
Implementing Aging in a Cache Group for TimesTen Classic
This section describes cache group definitions that contain an aging policy.
• LRU Aging in TimesTen Classic
• Time-Based Aging in TimesTen Classic
• Manually Scheduling an Aging Process in TimesTen Classic
• Configuring a Sliding Window in TimesTen Classic
The following example defines an LRU aging policy on the AWT cache group new_customers:
CREATE ASYNCHRONOUS WRITETHROUGH CACHE GROUP new_customers
FROM sales.customer
(cust_num NUMBER(6) NOT NULL,
region VARCHAR2(10),
name VARCHAR2(50),
address VARCHAR2(100),
PRIMARY KEY(cust_num))
AGING LRU ON;
4-43
Chapter 4
Implementing Aging in a Cache Group for TimesTen Classic
• Change the aging state of a cache group by specifying the root table and using the
SET AGING clause.
• Add an LRU aging policy to a cache group that has no aging policy defined by
specifying the root table and using the ADD AGING LRU clause.
• Drop the LRU aging policy on a cache group by specifying the root table and using
the DROP AGING clause.
To change the aging policy of a cache group from LRU to time-based, use an ALTER
TABLE statement on the root table with the DROP AGING clause to drop the LRU aging
policy. Then use an ALTER TABLE statement on the root table with the ADD AGING USE
clause to add a time-based aging policy.
You must stop the cache agent before you add, alter or drop an aging policy on a
cache group with autorefresh.
The following example are the definitions of the Oracle Database tables that are to be
cached in the AWT cache group. The Oracle Database tables are owned by the
schema user sales. The sales user must be granted the CREATE SESSION, CREATE
TRIGGER, CREATE SEQUENCE, CREATE TYPE, CREATE PROCEDURE, and CREATE TABLE
privileges before it can create tables.
CREATE TABLE orders
(ord_num NUMBER(10) NOT NULL PRIMARY KEY,
cust_num NUMBER(6) NOT NULL,
when_placed DATE NOT NULL,
when_shipped DATE NOT NULL);
The companion Oracle cache administration user must be granted the SELECT privilege
on the sales.orders and sales.order_item tables in order for the TimesTen cache
administration user to create an AWT cache group that caches these tables. The
Oracle cache administration user must be granted the INSERT, UPDATE and DELETE
Oracle Database privileges for the sales.orders and sales.order_item tables for
asynchronous writethrough operations to be applied on the Oracle Database.
The following example defines a time-based aging policy on the AWT cache group
ordered_items:
CREATE ASYNCHRONOUS WRITETHROUGH CACHE GROUP ordered_items
FROM sales.orders
(ord_num NUMBER(10) NOT NULL,
cust_num NUMBER(6) NOT NULL,
4-44
Chapter 4
Implementing Aging in a Cache Group for TimesTen Classic
Cache instances that are greater than 45 days old based on the difference between the
current system timestamp and the timestamp in the when_placed column of the sales.orders
table are candidates for aging. The aging process checks every 60 minutes to see if there are
cache instances that can be automatically aged out or deleted from the cache tables.
The AGING USE clause requires the name of a non-nullable TIMESTAMP or DATE column used
for time-based aging. We refer to this column as the timestamp column.
For each row, the value in the timestamp column stores the date and time when the row was
most recently inserted or updated. The values in the timestamp column is maintained by your
application. If the value of this column is unknown for particular rows and you do not want
those rows to be aged out of the table, define the timestamp column with a large default
value.
You can create an index on the timestamp column to optimize performance of the aging
process.
You cannot add a column to an existing table and then use that column as the timestamp
column because added columns cannot be defined as non-nullable. You cannot drop the
timestamp column from a table that has a time-based aging policy defined.
Specify the lifetime in days, hours, minutes or seconds after the LIFETIME keyword in the
AGING USE clause.
The value in the timestamp column is subtracted from the current system timestamp. The
result is then truncated to the specified lifetime unit (day, hour, minute, second) and
compared with the specified lifetime value. If the result is greater than the lifetime value, the
row is a candidate for aging.
After the CYCLE keyword, specify the frequency in which aging occurs in days, hours, minutes
or seconds. The default aging cycle is 5 minutes. If you specify an aging cycle of 0, aging is
continuous.
The ALTER TABLE statement can be used to perform the following tasks associated with
changing or defining a time-based aging policy on a cache group:
• Change the aging state of a cache group by specifying the root table and using the SET
AGING clause.
• Change the lifetime by specifying the root table and using the SET AGING LIFETIME
clause.
• Change the aging cycle by specifying the root table and using the SET AGING CYCLE
clause.
• Add a time-based aging policy to a cache group that has no aging policy defined by
specifying the root table and using the ADD AGING USE clause.
4-45
Chapter 4
Implementing Aging in a Cache Group for TimesTen Classic
• Drop the time-based aging policy on a cache group by specifying the root table
and using the DROP AGING clause.
To change the aging policy of a cache group from time-based to LRU, use an ALTER
TABLE statement on the root table with the DROP AGING clause to drop the time-based
aging policy. Then use an ALTER TABLE statement on the root table with the ADD AGING
LRU clause to add an LRU aging policy.
You must stop the cache agent before you add, alter or drop an aging policy on a
cache group with autorefresh.
The following example shows how the ttAgingScheduleNow built-in procedure starts a
one-time aging process on the sales.orders table based on the time
ttAgingScheduleNow is called:
Command> CALL ttAgingScheduleNow('sales.orders');
Rows in the sales.orders root table that are candidates for aging are deleted as well
as related rows in the sales.order_item child table.
When you call the ttAgingScheduleNow built-in procedure, the aging process starts
regardless of whether the table's aging state is ON or OFF. If you want to start an aging
process on a particular cache group, specify the name of the cache group's root table
when you call the built-in procedure. If the ttAgingScheduleNow built-in procedure is
called with no parameters, it starts an aging process and then resets the start of the
next aging cycle on all tables in the TimesTen database that have an aging policy
defined.
Calling the ttAgingScheduleNow built-in procedure does not change the aging state of
any table. If a table's aging state is OFF when you call the built-in procedure, the aging
process starts, but it is not scheduled to run again after the process has completed. To
continue aging a table whose aging state is OFF, you must call ttAgingScheduleNow
again or change the table's aging state to ON.
To manually control aging on a cache group, disable aging on the root table by using
an ALTER TABLE statement with the SET AGING OFF clause. Then call
ttAgingScheduleNow to start an aging process on the cache group.
4-46
Chapter 4
Replicating Cache Tables in TimesTen Classic
You can configure a sliding window for a cache group by using incremental autorefresh mode
and defining a time-based aging policy. The autorefresh operation checks the timestamp of
the rows in the cached Oracle Database tables to determine whether new data should be
refreshed into the TimesTen cache tables. The system time and the time zone must be
identical on the Oracle Database and TimesTen systems.
If the cache group does not use incremental autorefresh mode, you can configure a sliding
window by using a LOAD CACHE GROUP, REFRESH CACHE GROUP, or INSERT statement, or a
dynamic load operation to bring new data into the cache tables.
The following example configures a sliding window on the read-only cache group
recent_shipped_orders:
CREATE READONLY CACHE GROUP recent_shipped_orders
AUTOREFRESH MODE INCREMENTAL INTERVAL 1440 MINUTES STATE ON
FROM sales.orders
(ord_num NUMBER(10) NOT NULL,
cust_num NUMBER(6) NOT NULL,
when_placed DATE NOT NULL,
when_shipped DATE NOT NULL,
PRIMARY KEY(ord_num))
AGING USE when_shipped LIFETIME 30 DAYS CYCLE 24 HOURS ON;
New data in the sales.orders cached Oracle Database table are automatically refreshed into
the sales.orders TimesTen cache table every 1440 minutes. Cache instances that are
greater than 30 days old based on the difference between the current system timestamp and
the timestamp in the when_shipped column are candidates for aging. The aging process
checks every 24 hours to see if there are cache instances that can be aged out of the cache
tables. Therefore, this cache group stores orders that have been shipped within the last 30
days.
The autorefresh interval and the lifetime used for aging determine the duration that particular
rows remain in the cache tables. It is possible for data to be aged out of the cache tables
before it has been in the cache tables for its lifetime. For example, for a read-only cache
group if the autorefresh interval is 3 days and the lifetime is 30 days, data that is already 3
days old when it is refreshed into the cache tables is deleted after 27 days because aging is
based on the timestamp stored in the rows of the cached Oracle Database tables that gets
loaded into the TimesTen cache tables, not when the data is refreshed into the cache tables.
4-47
Chapter 4
Replicating Cache Tables in TimesTen Classic
Note:
This section describes one scenario in including cache groups within an
active standby pair replication scheme. See Administering an Active Standby
Pair with Cache Groups in Oracle TimesTen In-Memory Database
Replication Guide for more scenarios for including AWT and read-only cache
groups in an active standby pair replication scheme.
Oracle Real Application Clusters (Oracle RAC) provides for high availability of an
Oracle database. See Using Cache in an Oracle RAC Environment.
Perform the following tasks to configure an active standby pair for TimesTen Classic
databases that cache Oracle Database tables:
• Create and Configure the Active Database
• Create and Configure the Standby Database
• Create and Configure the Read-Only Subscriber Database
Start the ttIsql utility and connect to the cacheactive DSN as the instance
administrator to create the database. Then create the TimesTen cache administration
user cacheadmin whose name is the same as a companion Oracle cache
administration user.
Then, create a cache table user sales whose name is the same as the Oracle
Database schema user who owns the Oracle Database tables to be cached in the
TimesTen Classic database.
% ttIsql cacheactive
Command> CREATE USER cacheadmin IDENTIFIED BY timesten;
Command> CREATE USER sales IDENTIFIED BY timesten;
As the instance administrator, use the ttIsql utility to grant the TimesTen cache
administration user cacheadmin the privileges required as well as create an active
standby pair replication scheme which requires the ADMIN privilege:
Command> GRANT CREATE SESSION, CACHE_MANAGER,
CREATE ANY TABLE, ADMIN TO cacheadmin;
Command> exit
4-48
Chapter 4
Replicating Cache Tables in TimesTen Classic
Start the ttIsql utility and connect to the cacheactive DSN as the TimesTen cache
administration user. Set the Oracle cache administration user name and password by calling
the ttCacheUidPwdSet built-in procedure.
% ttIsql "DSN=cacheactive;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL ttCacheUidPwdSet('cacheadmin','orapwd');
If desired, you can test the connectivity between the active database and the Oracle
database using the instructions stated in Testing the Connectivity Between the TimesTen and
Oracle Databases.
Start the cache agent on the active database by calling the ttCacheStart built-in procedure
as the TimesTen cache administration user:
Command> CALL ttCacheStart;
The following statement is the definition of the Oracle Database table that is to be cached in a
dynamic AWT cache group. The Oracle Database table is owned by the schema user sales.
The sales user must be granted the CREATE SESSION, CREATE TRIGGER, CREATE SEQUENCE,
CREATE TYPE, CREATE PROCEDURE, and CREATE TABLE privileges before it can create tables.
CREATE TABLE subscriber
(subscriberid NUMBER(10) NOT NULL PRIMARY KEY,
name VARCHAR2(100) NOT NULL,
minutes_balance NUMBER(5) NOT NULL,
last_call_duration NUMBER(4) NOT NULL);
The Oracle cache administration user must be granted the SELECT privilege on the
sales.subscriber table so that the TimesTen cache administration user can create an AWT
cache group that caches this table. The Oracle cache administration user must be granted
the INSERT, UPDATE and DELETE Oracle Database privileges for the sales.subscriber table
for asynchronous writethrough operations to be applied to the Oracle Database.
Then, create cache groups in the TimesTen Classic database with the CREATE DYNAMIC
ASYNCHRONOUS WRITETHROUGH CACHE GROUP statement as the TimesTen cache administration
user. For example, the following statement creates a dynamic AWT cache group
subscriber_accounts that caches the sales.subscriber table:
CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH CACHE GROUP subscriber_accounts
FROM sales.subscriber
(subscriberid NUMBER(10) NOT NULL PRIMARY KEY,
name VARCHAR2(100) NOT NULL,
minutes_balance NUMBER(5) NOT NULL,
last_call_duration NUMBER(4) NOT NULL);
As the TimesTen cache administration user, create an active standby pair replication scheme
in the active database using a CREATE ACTIVE STANDBY PAIR statement.
In the following example, cacheact, cachestand and subscr are the file name prefixes of the
checkpoint and transaction log files of the active database, standby database and read-only
subscriber database. sys3, sys4 and sys5 are the host names of the TimesTen systems
where the active database, standby database and read-only subscriber database reside,
respectively.
Command> CREATE ACTIVE STANDBY PAIR cacheact ON "sys3", cachestand ON "sys4"
SUBSCRIBER subscr ON "sys5";
4-49
Chapter 4
Replicating Cache Tables in TimesTen Classic
As the TimesTen cache administration user, start the replication agent on the active
database by calling the ttRepStart built-in procedure. Then declare the database as
the active by calling the ttRepStateSet built-in procedure.
Command> CALL ttRepStart;
Command> CALL ttRepStateSet('active');
As the instance administrator, create the standby database as a duplicate of the active
database by running a ttRepAdmin -duplicate utility command from the standby
database system. The instance administrator user name of the active database's and
standby database's instances must be identical.
Use the -keepCG option so that cache tables in the active database are duplicated as
cache tables in the standby database, because the standby database is connected
with the Oracle database.
In the following example:
• The -from option specifies the file name prefix of the active database's checkpoint
and transaction log files.
• The -host option specifies the host name of the TimesTen system where the
active database resides.
• The -uid and -pwd options specify a user name and password of a TimesTen
internal user defined in the active database that has been granted the ADMIN
privilege.
• The -cacheuid and -cachepwd options specify the Oracle cache administration
user name and password.
• cachestandby is the DSN of the standby database.
• The -keepCG option specifies that the standby database keeps the cache groups
defined on the active database.
% ttRepAdmin -duplicate -from cacheact -host "sys3" -uid cacheadmin -pwd timesten
-cacheuid cacheadmin -cachepwd orapwd -keepCG cachestandby
Start the ttIsql utility and connect to the cachestandby DSN as the TimesTen cache
administration user. Set the Oracle cache administration user name and password by
calling the ttCacheUidPwdSet built-in procedure.
% ttIsql "DSN=cachestandby;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL ttCacheUidPwdSet('cacheadmin','orapwd');
4-50
Chapter 4
Replicating Cache Tables in TimesTen Classic
If desired, you can test the connectivity between the standby database and the Oracle
database using the instructions stated in Testing the Connectivity Between the TimesTen and
Oracle Databases.
Start the cache agent on the standby database by calling the ttCacheStart built-in procedure
as the TimesTen cache administration user:
Command> CALL ttCacheStart;
As the TimesTen cache administration user, start the replication agent on the standby
database by calling the ttRepStart built-in procedure.
Command> CALL ttRepStart;
As the instance administrator, create the read-only subscriber database as a duplicate of the
standby database by running a ttRepAdmin -duplicate utility command from the read-only
subscriber database system. The instance administrator user name of the standby database
and read-only subscriber database must be identical.
Use the -noKeepCG option so that cache tables in the standby database are duplicated as
regular tables in the read-only subscriber database because the read-only subscriber
database is not connected with the Oracle database.
In the following example:
• The -from option specifies the file name prefix of the standby database's checkpoint and
transaction log files.
• The -host option specifies the host name of the TimesTen system where the standby
database resides.
• The -uid and -pwd options specify a user name and password of a TimesTen internal
user defined in the standby database that has been granted the ADMIN privilege.
• rosubscriber is the DSN of the read-only subscriber database.
% ttRepAdmin -duplicate -from cachestand -host "sys4" -uid cacheadmin -pwd timesten
-noKeepCG rosubscriber
As the TimesTen cache administration user, start the replication agent on the read-only
subscriber database by calling the ttRepStart built-in procedure.
% ttIsql "DSN=rosubscriber;UID=cacheadmin;PWD=timesten"
Command> CALL ttRepStart;
Command> exit
4-51
5
Methods for Transmitting Changes Between
TimesTen and Oracle Databases
You can transmit changes between TimesTen and Oracle databases manually or
automatically.
• Manually load cache groups: You can manually load or refresh cache instances into the
TimesTen cache tables from the Oracle database tables using LOAD CACHE GROUP or
REFRESH CACHE GROUP statements.
• Manually propagate committed changes: Use a FLUSH CACHE GROUP statement to
propagate committed changes on the TimesTen cache tables to the cached Oracle
Database tables.
• Automatically refresh cache groups: You can cause the cache instances to be
automatically refreshed with the AUTOREFRESH cache table attribute. Automatic refresh can
be defined on cache groups that are either explicitly or dynamically loaded.
• Dynamically load data on demand: When you define a cache group with the DYNAMIC
keyword, then the data in a cache group is dynamically loaded on demand.
• Automatic propagation of changes to the Oracle database: When you configure the
PROPAGATE cache table attribute on the TimesTen cache tables, then committed changes
are automatically propagated to the cached Oracle Database tables.
See Transmitting Changes Between the TimesTen and Oracle Databases for an overview of
each of these methods.
Note:
You can use SQL statements or SQL Developer to perform most of the operations
in this chapter. For more information about SQL Developer, see Oracle TimesTen
In-Memory Database SQL Developer Support User's Guide.
5-1
Chapter 5
Manually Loading and Refreshing a Cache Group
If the cache group has a time-based aging policy defined, only cache instances where
the timestamp in the root table's row is within the aging policy's lifetime are loaded or
refreshed into the cache tables.
To prevent a load or refresh operation from processing a large number of cache
instances within a single transaction, which can greatly reduce concurrency and
throughput, use the COMMIT EVERY n ROWS clause to specify a commit frequency unless
5-2
Chapter 5
Manually Loading and Refreshing a Cache Group
you are using the WITH ID clause. If you specify COMMIT EVERY 0 ROWS, the load or refresh
operation is processed in a single transaction.
In addition, if the load operation is for a large amount of data, use parallelism to increase
throughput by specifying the number of threads with the PARALLEL clause.
A LOAD CACHE GROUP or REFRESH CACHE GROUP statement that uses the COMMIT EVERY n ROWS
clause must be performed in its own transaction without any other operations within the same
transaction.
The following example loads new cache instances into the TimesTen cache tables in the
customer_orders cache group from the cached Oracle Database tables:
LOAD CACHE GROUP customer_orders COMMIT EVERY 256 ROWS PARALLEL 3;
The following example loads into the TimesTen cache tables using a WHERE clause in the
new_customers cache group from the cached Oracle Database tables. The WHERE clause
specifies new cache instances for customers whose customer number is greater than or
equal to 5000:
LOAD CACHE GROUP new_customers WHERE (sales.customer.cust_num >= 5000)
COMMIT EVERY 256 ROWS;
The following example refreshes cache instances in the TimesTen cache tables within the
top_products cache group from the cached Oracle Database tables:
REFRESH CACHE GROUP top_products COMMIT EVERY 256 ROWS;
The following example refreshes in the TimesTen cache tables within the
update_anywhere_customers cache group from the cached Oracle Database tables. The
WHERE clause specifies cache instances of customers located in zip code 60610:
REFRESH CACHE GROUP update_anywhere_customers
WHERE (sales.customer.zip = '60610') COMMIT EVERY 256 ROWS;
See LOAD CACHE GROUP and REFRESH CACHE GROUP in Oracle TimesTen In-Memory
Database SQL Reference.
The rest of this section includes these topics:
• Loading and Refreshing a Cache Group Using a WITH ID Clause
• Loading and Refreshing a Multiple-Table Cache Group
• Improving the Performance of Loading or Refreshing a Large Number of Cache
Instances
• Example of Manually Loading and Refreshing a Static Cache Group
• Example of Manually Loading and Refreshing a Dynamic Cache Group
The WITH ID clause is more convenient than the equivalent WHERE clause if the primary key
contains more than one column. Using the WITH ID clause allows you to load one cache
instance at a time. It also enables you to roll back the transaction containing the load or
5-3
Chapter 5
Manually Loading and Refreshing a Cache Group
refresh operation, if necessary, unlike the equivalent statement that uses a WHERE
clause because using a WHERE clause also requires specifying a COMMIT EVERY n ROWS
clause.
The following example loads a cache group using a WITH ID clause. A cache group
recent_orders contains a single cache table sales.orderdetails with a primary key
of (orderid, itemid). If a customer calls about an item within a particular order, the
information can be obtained by loading the cache instance for the specified order
number and item number.
Load the sales.orderdetails cache table in the recent_orders cache group with the
row whose value in the orderid column of the sales.orderdetails cached Oracle
Database table is 1756 and its value in the itemid column is 573:
LOAD CACHE GROUP recent_orders WITH ID (1756,573);
The following is an equivalent LOAD CACHE GROUP statement that uses a WHERE clause:
LOAD CACHE GROUP recent_orders WHERE orderid = 1756 and itemid = 573
COMMIT EVERY 256 ROWS;
A LOAD CACHE GROUP or REFRESH CACHE GROUP statement issued on a cache group with
autorefresh cannot contain a WITH ID clause unless the cache group is dynamic.
You cannot use the COMMIT EVERY n ROWS clause with the WITH ID clause.
This causes TimesTen to query the cached Oracle Database tables in a serializable
fashion during the load or refresh operation so that the loaded or refreshed cache
instances in the cache tables are guaranteed to be transactionally consistent with the
corresponding rows in the cached Oracle Database tables. After you have loaded or
refreshed the cache group, set the isolation level back to read committed for better
concurrency when accessing elements in the TimesTen database.
Specify the number of threads to use when processing the load or refresh operation.
You can specify 1 to 10 threads. One thread fetches rows from the cached Oracle
Database tables, while the other threads insert the rows into the TimesTen cache
tables. Do not specify more threads than the number of CPUs available on your
system or you may encounter decreased performance than if you had not used the
PARALLEL clause.
5-4
Chapter 5
Manually Loading and Refreshing a Cache Group
Note:
You cannot use the WITH ID clause with the PARALLEL clause. You can use the
COMMIT EVERY n ROWS clause with the PARALLEL clause as long as n is greater than
0. In addition, you cannot use the PARALLEL clause for read-only dynamic cache
groups or when database level locking is enabled. See REFRESH CACHE GROUP
in the Oracle TimesTen In-Memory Database SQL Reference.
The following example refreshes cache instances in the TimesTen cache tables using a
PARALLEL clause. This example refreshes the western_customers cache group from the
cached Oracle Database tables using one thread to fetch rows from the cached Oracle
Database tables and three threads to insert the rows into the cache tables:
REFRESH CACHE GROUP western_customers COMMIT EVERY 256 ROWS PARALLEL 4;
The following is the data in the sales.customer cached Oracle Database table.
CUST_NUM REGION NAME ADDRESS
-------- ------- --------------- ---------------------------
1 West Frank Edwards 100 Pine St. Portland OR
2 East Angela Wilkins 356 Olive St. Boston MA
3 Midwest Stephen Johnson 7638 Walker Dr. Chicago IL
The following statement creates a static AWT cache group new_customers that caches the
sales.customer table:
CREATE ASYNCHRONOUS WRITETHROUGH CACHE GROUP new_customers
FROM sales.customer
(cust_num NUMBER(6) NOT NULL,
region VARCHAR2(10),
name VARCHAR2(50),
address VARCHAR2(100),
PRIMARY KEY(cust_num));
The following LOAD CACHE GROUP statement loads the three cache instances from the cached
Oracle Database table into the TimesTen cache table:
5-5
Chapter 5
Manually Loading and Refreshing a Cache Group
Update the cached Oracle Database table by inserting a new row, updating an existing
row, and deleting an existing row:
SQL> INSERT INTO customer
2 VALUES (4, 'East', 'Roberta Simon', '3667 Park Ave. New York NY');
SQL> UPDATE customer SET name = 'Angela Peterson' WHERE cust_num = 2;
SQL> DELETE FROM customer WHERE cust_num = 3;
SQL> COMMIT;
SQL> SELECT * FROM customer;
CUST_NUM REGION NAME ADDRESS
-------- ------- --------------- ---------------------------
1 West Frank Edwards 100 Pine St. Portland OR
2 East Angela Peterson 356 Olive St. Boston MA
4 East Roberta Simon 3667 Park Ave. New York NY
The following is the data in the sales.customer cached Oracle Database table.
CUST_NUM REGION NAME ADDRESS
-------- ------- --------------- ---------------------------
1 West Frank Edwards 100 Pine St. Portland OR
2 East Angela Wilkins 356 Olive St. Boston MA
3 Midwest Stephen Johnson 7638 Walker Dr. Chicago IL
The following statement creates a dynamic AWT cache group new_customers that
caches the sales.customer table:
5-6
Chapter 5
Manually Loading and Refreshing a Cache Group
The following LOAD CACHE GROUP statement loads the three cache instances from the cached
Oracle Database table into the TimesTen cache table:
Command> LOAD CACHE GROUP new_customers COMMIT EVERY 256 ROWS;
3 cache instances affected.
Command> SELECT * FROM sales.customer;
< 1, West, Frank Edwards, 100 Pine St. Portland OR >
< 2, East, Angela Wilkins, 356 Olive St. Boston MA >
< 3, Midwest, Stephen Johnson, 7638 Walker Dr. Chicago IL >
Update the cached Oracle Database table by inserting a new row, updating an existing row,
and deleting an existing row:
SQL> INSERT INTO customer
2 VALUES (4, 'East', 'Roberta Simon', '3667 Park Ave. New York NY');
SQL> UPDATE customer SET name = 'Angela Peterson' WHERE cust_num = 2;
SQL> DELETE FROM customer WHERE cust_num = 3;
SQL> COMMIT;
SQL> SELECT * FROM customer;
CUST_NUM REGION NAME ADDRESS
-------- ------- --------------- ---------------------------
1 West Frank Edwards 100 Pine St. Portland OR
2 East Angela Peterson 356 Olive St. Boston MA
4 East Roberta Simon 3667 Park Ave. New York NY
A REFRESH CACHE GROUP statement issued on a dynamic cache group only refreshes
committed updates and deletes on the cached Oracle Database tables into the cache tables.
New cache instances are not loaded into the cache tables. Therefore, only existing cache
instances are refreshed. As a result, the number of cache instances in the cache tables are
either fewer than or the same as the number of rows in the cached Oracle Database tables.
Command> REFRESH CACHE GROUP new_customers COMMIT EVERY 256 ROWS;
2 cache instances affected.
Command> SELECT * FROM sales.customer;
< 1, West, Frank Edwards, 100 Pine St. Portland OR >
< 2, East, Angela Peterson, 356 Olive St. Boston MA >
A subsequent LOAD CACHE GROUP statement loads one cache instance from the cached
Oracle Database table into the TimesTen cache table because only committed inserts are
loaded into the cache table. Therefore, only new cache instances are loaded. Cache
instances that already exist in the cache tables are not changed because of a LOAD CACHE
GROUP statement, even if the corresponding rows in the cached Oracle Database tables were
updated or deleted.
Command> LOAD CACHE GROUP new_customers COMMIT EVERY 256 ROWS;
1 cache instance affected.
Command> SELECT * FROM sales.customer;
5-7
Chapter 5
Flushing a User Managed Cache Group
You can flush a user managed cache group with the FLUSH CACHE GROUP statement if
at least one of its cache tables uses neither the PROPAGATE nor the READONLY cache
table attribute.
You can use a WHERE clause or WITH ID clause in a FLUSH CACHE GROUP statement to
restrict the rows to be flushed to the cached Oracle Database tables.
The following example flushes a cache group with the FLUSH CACHE GROUP statement.
It manually propagates committed insert and update operations on the TimesTen
cache tables in the western_customers cache group to the cached Oracle Database
tables:
FLUSH CACHE GROUP western_customers;
See PROPAGATE Cache Table Attribute in this book and CREATE CACHE GROUP in
the Oracle TimesTen In-Memory Database SQL Reference.
5-8
Chapter 5
Unloading a Cache Group
Unlike the DROP CACHE GROUP statement, the cache tables themselves are not dropped when
a cache group is unloaded.
To prevent an unload operation from processing a large number of cache instances within a
single transaction, which could reduce concurrency and throughput, use the COMMIT EVERY n
ROWS clause to specify a commit frequency.
Use caution when using the UNLOAD CACHE GROUP statement with cache groups with
autorefresh. An unloaded row can reappear in the cache table as the result of an autorefresh
operation if the row, or its related parent or child rows, are updated in the cached Oracle
Database table.
Processing of the UNLOAD CACHE GROUP statement for an AWT cache group waits until
updates on the rows have been propagated to the Oracle database.
The following example unloads all cache instances from all cache tables in the
customer_orders cache group. A commit frequency is specified, so the operations is
performed over several transactions by committing every 256 rows:
UNLOAD CACHE GROUP customer_orders COMMIT EVERY 256 ROWS;
The following statement unloads all cache instances from all cache tables in the
customer_orders cache group in a single transaction. A single transaction should only be
used if the data within customer_orders is small:
UNLOAD CACHE GROUP customer_orders;
The following equivalent statements delete the cache instance for customer number 227 from
the cache tables in the new_customers cache group:
UNLOAD CACHE GROUP new_customers WITH ID (227);
UNLOAD CACHE GROUP new_customers WHERE (sales.customer.cust_num = 227);
See UNLOAD CACHE GROUP in the Oracle TimesTen In-Memory Database SQL
Reference.
5-9
Chapter 5
Automatically Refreshing a Cache Group
AUTOREFRESH specifies that committed changes on cached Oracle Database tables are
automatically refreshed to the TimesTen cache tables. Autorefresh is defined by
default on read-only cache groups.
The following are the default settings of the autorefresh attributes:
• The autorefresh mode is incremental.
• The autorefresh interval is 5 minutes.
• The autorefresh state is PAUSED.
If you create a unique index on a cache group with the AUTOREFRESH cache group
attribute, the index is changed to a non-unique index to avoid a constraint violation. A
constraint violation could occur with a unique index because conflicting updates could
occur in the same statement processing on the Oracle Database table, while each row
update is processed separately in TimesTen. If the unique index exists on the Oracle
Database table that is being cached, then uniqueness is enforced on the Oracle
Database table and does not need to be verified again in TimesTen.
The following sections describe each of the autorefresh attributes:
• Autorefresh Mode Attribute Settings
• Autorefresh Interval and State Settings
• Restrictions for Autorefresh
5-10
Chapter 5
Automatically Refreshing a Cache Group
Even if you use incremental autorefresh on your cache group, the first load is a full refresh. In
addition, TimesTen may perform a full autorefresh for recovery for certain error scenarios.
Note:
You can disallow full autorefresh with the DisableFullAutorefresh cache
configuration parameter. See Disabling Full Autorefresh for Cache Groups.
When using incremental autorefresh mode, committed changes on cached Oracle Database
tables are tracked in change log tables in the Oracle database. Because incremental
autorefresh tracks committed changes on the Oracle database, incremental autorefresh
mode incurs some overhead to refresh the cache group for each committed update on the
cached Oracle Database tables. Under certain circumstances, it is possible for some change
log records to be deleted (truncated) from the change log table before they are automatically
refreshed to the TimesTen cache tables. If this occurs, TimesTen initiates a full automatic
refresh on the cache group.
See Managing the Cache Administration User's Tablespace for information on how to
configure an action to take when the tablespace that the change log tables reside in becomes
full.
See Managing a Cache Environment With Oracle Database Objects for information on the
change log tables in the Oracle Database.
The change log table on the Oracle database does not have column-level resolution because
of performance reasons. Thus, the autorefresh operation updates all of the columns in a row.
XLA reports that all of the columns in the row have changed even if the data did not actually
change in each column. See XLA and TimesTen Event Management in the Oracle TimesTen
In-Memory Database C Developer's Guide or Using JMS/XLA for Event Management in the
Oracle TimesTen In-Memory Database Java Developer's Guide.
If you have a dynamic read-only cache group with autorefresh, you can reduce contention
and improve performance. See Reducing Contention for Dynamic Read-Only Cache Groups
With Incremental Autorefresh and Reducing Lock Contention for Read-Only Cache Groups
With Autorefresh and Dynamic Load and Options for Reducing Contention Between
Autorefresh and Dynamic Load Operations.
5-11
Chapter 5
Automatically Refreshing a Cache Group
• ON: Autorefresh operations are scheduled by TimesTen when the cache group's
autorefresh state is ON.
• OFF: When the cache group's autorefresh state is OFF, committed changes on the
cached Oracle Database tables are not tracked.
• PAUSED: When the cache group's autorefresh state is PAUSED, committed changes
on the cached Oracle Database tables are tracked in the Oracle database, but are
not automatically refreshed to the TimesTen cache tables until the state is changed
to ON.
By default, a cache group is created with autorefresh state set to PAUSED. This provides
you a choice of how and when the initial full load is performed. If the data in the Oracle
database is large, then an initial full load of the cache group can prove to be time
consuming. The recommended option is to run a manual load with parallelism with the
LOAD CACHE GROUP... PARALLEL statement. The autorefresh state automatically
changes to ON after the load completes.
If the data on the Oracle database is small, change the state to ON with an ALTER
CACHE GROUP so that the initial load is performed and autorefresh operations start.
If the data on the Oracle database is too large to perform an initial full load, you can
disable all full load operations. See Disabling Full Autorefresh for Cache Groups.
• TimesTen Scaleout only supports static read-only cache groups with incremental
autorefresh. See Using Cache Groups in TimesTen Scaleout in the Oracle
TimesTen In-Memory Database Scaleout User's Guide.
• A FLUSH CACHE GROUP statement cannot be issued on the cache group.
See Flushing a User Managed Cache Group.
• A TRUNCATE TABLE statement issued on a cached Oracle Database table is not
automatically refreshed to the TimesTen cache table. Before issuing a TRUNCATE
TABLE statement on a cached Oracle Database table, use an ALTER CACHE GROUP
statement to change the autorefresh state of the cache group that contains the
cache table to PAUSED.
See Altering a Cache Group to Change the AUTOREFRESH Mode, Interval or
State.
After issuing the TRUNCATE TABLE statement on the cached Oracle Database table,
use a REFRESH CACHE GROUP statement to manually refresh the cache group.
• A LOAD CACHE GROUP statement can only be issued if the cache tables are empty,
unless the cache group is dynamic.
See Manually Loading and Refreshing a Cache Group and Creating a Dynamic
Cache Group With the DYNAMIC Keyword.
• The autorefresh state must be PAUSED before you can issue a LOAD CACHE GROUP
statement on the cache group, unless the cache group is dynamic. If the cache
group is dynamic, the autorefresh state must be PAUSED or ON.
5-12
Chapter 5
Automatically Refreshing a Cache Group
• The LOAD CACHE GROUP statement cannot contain a WHERE clause, unless the cache group
is dynamic. If the cache group is dynamic, the WHERE clause must be followed by a COMMIT
EVERY n ROWS clause.
See Using a WHERE Clause.
• The autorefresh state must be PAUSED before you can issue a REFRESH CACHE GROUP
statement on the cache group. The REFRESH CACHE GROUP statement cannot contain a
WHERE clause.
• All tables and columns referenced in WHERE clauses when creating, loading or unloading
the cache group must be fully qualified. For example:
owner.table_name and owner.table_name.column_name
• To use the AUTOREFRESH cache group attribute in a user managed cache group, all of the
cache tables must be specified with the PROPAGATE cache table attribute or all of the
cache tables must be specified the READONLY cache table attribute.
• You cannot specify the AUTOREFRESH cache group attribute in a user managed cache
group that contains cache tables that explicitly use the NOT PROPAGATE cache table
attribute.
• The AUTOREFRESH cache table attribute cannot be used when caching Oracle Database
materialized views in a user managed cache group.
• LRU aging cannot be specified on the cache group, unless the cache group is dynamic
where LRU aging is defined by default.
See LRU Aging in TimesTen Classic.
• If you want to use replication with a static cache group with autorefresh on TimesTen
Classic, you can only use an active standby pair replication scheme. Any other type of
replication scheme is not allowed with a static cache group with autorefresh on TimesTen
Classic.
5-13
Chapter 5
Automatically Refreshing a Cache Group
The following example alters the autorefresh attributes of a cache group in TimesTen
Classic. These statements change the autorefresh mode, interval and state of the
customer_orders cache group:
ALTER CACHE GROUP customer_orders SET AUTOREFRESH MODE FULL;
ALTER CACHE GROUP customer_orders SET AUTOREFRESH INTERVAL 30 SECONDS;
ALTER CACHE GROUP customer_orders SET AUTOREFRESH STATE ON;
TimesTen returns asynchronously after executing the ALTER CACHE GROUP statement.
However, there may be a delay for the cache agent to implement the change for the
new state, mode or interval.
Note:
The ttCacheSQLGet built-in procedure provides the same functionality as
the ttISql cachesqlget command.
3. Use SQL*Plus to run the script generated by the ttIsql utility's cachesqlget
command as the sys user.
4. Run an ALTER CACHE GROUP statement to change the autorefresh state of the
cache group to PAUSED.
The following examples shows how to create a read-only cache group when Oracle
Database objects are created with the initCacheAdminSchema.sql script.
The first statement creates a read-only cache group customer_orders with the
autorefresh state set to OFF. The SQL*Plus script generated by the ttIsql utility's
cachesqlget command is saved to the /tmp/obj.sql file. The last statement changes
the autorefresh state of the cache group to PAUSED.
CREATE READONLY CACHE GROUP customer_orders
AUTOREFRESH STATE OFF
FROM sales.customer
(cust_num NUMBER(6) NOT NULL,
region VARCHAR2(10),
5-14
Chapter 5
Automatically Refreshing a Cache Group
name VARCHAR2(50),
address VARCHAR2(100),
PRIMARY KEY(cust_num)),
sales.orders
(ord_num NUMBER(10) NOT NULL,
cust_num NUMBER(6) NOT NULL,
when_placed DATE NOT NULL,
when_shipped DATE NOT NULL,
PRIMARY KEY(ord_num),
FOREIGN KEY(cust_num) REFERENCES sales.customer(cust_num));
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> cachesqlget INCREMENTAL_AUTOREFRESH customer_orders INSTALL /tmp/obj.sql;
Command> exit
The refresh operation is full or incremental depending on how the cache group is configured.
The autorefresh state must be ON when ttCacheAutorefresh is called.
The autorefresh operation typically refreshes all cache groups sharing the same refresh
interval in one transaction in order to preserve transactional consistency across these cache
groups. Therefore, although you specify a specific cache group when you call
ttCacheAutorefresh, the autorefresh operation occurs in one transaction for all cache
groups that share the autorefresh interval with the specified cache group. If there is an
existing transaction with table locks on objects that belong to the affected cache groups,
ttCacheAutofresh returns an error without taking any action.
After calling ttCacheAutorefresh, you must commit or roll back the transaction before
subsequent work can be performed.
This example calls ttCacheAutorefresh for the ttuser.western_customers cache group,
using asynchronous mode.
Command> call ttCacheAutorefresh('ttuser', 'western_customers');
5-15
Chapter 5
Automatically Refreshing a Cache Group
Note:
The default value is 0 for the DisableFullAutorefresh cache configuration
parameter, which specifies full autorefresh behavior. Full autorefresh is only
supported on TimesTen Classic.
call ttCacheConfig('DisableFullAutorefresh',,,'1');
If a full autorefresh is triggered for a cache group, TimesTen changes the cache group
status to disabled. After which, all autorefresh operations cease on the cache group.
You are notified of this action with a message logged in both the daemon and user log
files. See Error, Warning, and Informational Messages in the Oracle TimesTen In-
Memory Database Operations Guide.
The TimesTen database status is set to recovering when at least one of its cache
groups have an autorefresh status of disabled or recovering. You can check the
state of a database and cache group with the ttCacheDbCgStatus built-in procedure.
The following example shows that:
• Recovering: Some or all the cache groups with the AUTOREFRESH attribute in the
database are being resynchronized with the Oracle database server. The status of
at least one cache group is recovering.
• Disabled: The cg1 cache group is disabled.
Command> call ttCacheDbCgStatus('ttuser','cg1');
< recovering, disabled >
1 row found.
5-16
Chapter 5
Automatically Refreshing a Cache Group
cached Oracle Database tables. The cache group must be recovered in order to
resynchronize the cache tables with the cached Oracle Database tables.
• For each cache group whose autorefresh status is disabled, a REFRESH CACHE GROUP
statement must be issued in order to resume autorefresh operations for these cache
groups.
• For each dynamic cache group whose autorefresh status is disabled, an UNLOAD CACHE
GROUP statement must be issued in order to resume autorefresh operations for these
cache groups.
• See Impact of Failed Autorefresh Operations on TimesTen Databases for details on how
to specify recovery when the autorefresh status of a cache group is dead.
The following example shows the steps to manually refresh a disabled cache group.
1. Pause autorefresh for the cache group and return the cache group status to OK with the
ALTER CACHE GROUP SET AUTOREFRESH STATE PAUSED statement.
2. Manually request a full refresh with the REFRESH CACHE GROUP statement (optionally, with
parallelism).
ALTER CACHE GROUP cg_static SET AUTOREFRESH STATE PAUSED;
REFRESH CACHE GROUP cg_static COMMIT EVERY 500 ROWS PARALLEL 3;
5-17
Chapter 5
Automatically Refreshing a Cache Group
• Its cache tables are initially empty, and then a dynamic load, a LOAD CACHE GROUP
or an unconditional REFRESH CACHE GROUP statement issued on the cache group
completes.
• Its cache tables are not empty, and then an unconditional REFRESH CACHE GROUP
statement issued on the cache group completes.
If the autorefresh state of a dynamic cache group is PAUSED, the autorefresh state
remains at PAUSED after any of the following events occur:
• Its cache tables are initially empty, and then a REFRESH CACHE GROUP ... WITH ID
statement issued on the cache group completes.
• Its cache tables are not empty, and then a dynamic load, a REFRESH CACHE
GROUP ... WITH ID, or a LOAD CACHE GROUP statement issued on the cache group
completes.
For a dynamic cache group, an autorefresh operation is similar to a REFRESH CACHE
GROUP statement that only refreshes committed updates and deletes on the cached
Oracle Database tables since the last autorefresh cycle into the cache tables because
only existing cache instances in the cache tables are refreshed. New cache instances
are not loaded into the cache tables. To load new cache instances into the cache
tables of a dynamic cache group, use a LOAD CACHE GROUP statement or perform a
dynamic load operation. See Dynamic Cache Groups.
The following restrictions apply when manually loading or refreshing a dynamic cache
group with automatic refresh:
• The autorefresh state must be PAUSED or ON before you can issue a LOAD CACHE
GROUP statement.
• The autorefresh state must be PAUSED before you can issue a REFRESH CACHE
GROUP statement.
• A LOAD CACHE GROUP statement that contains a WHERE clause must include a
COMMIT EVERY n ROWS clause after the WHERE clause.
• A REFRESH CACHE GROUP statement cannot contain a WHERE clause.
• All tables and columns referenced in a WHERE clause when loading the cache
group must be fully qualified. For example:
5-18
Chapter 5
Manually or Dynamically Loading Cache Groups
Note:
A static cache group is one that is created without the DYNAMIC keyword. Static
cache groups are supported in both TimesTen Classic and TimesTen Scaleout. See
Using Cache Groups in TimesTen Scaleout in the Oracle TimesTen In-Memory
Database Scaleout User's Guide.
A dynamic cache group is created with the DYNAMIC keyword. Dynamic cache
groups are only supported in TimesTen Classic.
• Manually loaded: You can manually load data into either a static cache group or a
dynamic cache group. You will always manually load data into a static cache group.
Perform the initial load of data into either static or dynamic cache groups from cached
Oracle Database tables using a LOAD CACHE GROUP statement.
• Dynamically loaded on demand: For dynamic cache groups only, TimesTen can
dynamically load data on demand. Data is automatically loaded into the TimesTen cache
tables from the cached Oracle Database tables when a qualifying SELECT, INSERT,
UPDATE, or DELETE statement is issued on one of the cache tables and the data does not
exist in the cache table but does exist in the cached Oracle Database table.
With both static and dynamic cache groups, a LOAD CACHE GROUP statement manually loads
into the designated cache tables qualified data that exists in the cached Oracle Database
tables but not in the cache tables in TimesTen. However, if a row exists in a cache table but a
newer version exists in the cached Oracle Database table, a LOAD CACHE GROUP statement
does not load that row into the cache table even if it satisfies the predicate of the statement.
By contrast, a REFRESH CACHE GROUP statement manually reloads qualifying rows that exists
in the cache tables, effectively refreshing the content of the cache. For a static cache group,
the rows that are refreshed are all the rows that satisfy the predicate of the REFRESH CACHE
GROUP statement. However, for a dynamic cache group, the rows that are refreshed are the
ones that satisfy the predicate and already exist in the cache tables. In other words, rows that
end up being refreshed are the ones that have been updated or deleted in the cached Oracle
Database table, but not the ones that have been inserted. Therefore, a refresh operation
processes only the rows that are already in the cache tables. No new rows are loaded into
the cache tables of a dynamic cache group as a result of a refresh.
The data in the cache instance of a dynamic read-only cache group is consistent with the
data in the corresponding rows of the Oracle Database tables. At any instant in time, the data
in a cache instance of a static cache group is consistent with the data in the corresponding
rows of the Oracle Database tables, taking into consideration the state and the interval
settings for autorefresh.
5-19
Chapter 5
Dynamic Cache Groups
Note:
The REFRESH CACHE GROUP statement and autorefresh are used to update or
delete cache instances that already exist in the TimesTen database. You can
use autorefresh to automatically populate changes made to cache instances
in the Oracle Database.
For example, a call center application may not want to preload all of its customers'
information into TimesTen as it may be very large. Instead, you can define the cache
group with the DYNAMIC keyword. After which, the cache group can use dynamic load
on demand so that a specific customer's information is loaded only when needed such
as when the customer calls or logs onto the system.
This following example creates a dynamic read-only cache group online_customers
that caches the sales.customer table:
CREATE DYNAMIC READONLY CACHE GROUP online_customers
FROM sales.customer
(cust_num NUMBER(6) NOT NULL,
region VARCHAR2(10),
name VARCHAR2(50),
address VARCHAR2(100),
PRIMARY KEY(cust_num));
Any system managed cache group type (read-only, AWT, SWT or hybrid) can be
defined with the DYNAMIC keyword. A user managed cache group can be defined with
the DYNAMIC keyword unless it uses both the AUTOREFRESH and the PROPAGATE cache
table attributes.
5-20
Chapter 5
Dynamic Cache Groups
Note:
If you have a dynamic read-only cache group with incremental autorefresh, you can
reduce contention and improve performance with either of the methods described in
Options for Reducing Contention Between Autorefresh and Dynamic Load
Operations.
When a cache group is enabled for dynamic load, a cache instance is uniquely identified
either by a primary key, a unique index on any table, or a foreign key of a child table. If a row
in the cached Oracle Database table satisfies the WHERE clause and the row is not in the
TimesTen database, then the entire associated cache instance is loaded in order to maintain
the defined relationships between primary keys and foreign keys of the parent and child
tables. When a cache group is enabled for dynamic load, the dynamic load operation typically
loads only one cache instance into the root table of any cache group, unless you specifically
request to load multiple cache instances (as described in Dynamically Loading Multiple
Cache Instances).
The WHERE clause must specify one of the following for a dynamic load to occur:
• An equality condition with constants and/or parameters on all columns of a primary key or
a foreign key of any table of the cache group. If more than one table of a cache group is
referenced, each must be connected by an equality condition on the primary or foreign
key relationship.
• A mixture of equality or IS NULL conditions on all columns of a unique index, provided
that you use at least one equality condition. That is, you can perform a dynamic load
where some columns of the unique index are NULL. The unique index must be created on
the root table of the cache group.
Note:
Dynamic loading based on a primary key search of the root table performs faster
than primary key searches on a child table or foreign key searches on a child table.
The dynamic load runs in a different transaction than the user transaction that triggers the
dynamic load. The dynamic load transaction is committed before the SQL statement that
triggers the dynamic load has finished processing. Thus, if the user transaction is rolled back,
the dynamically loaded data remains in the cache group.
Note:
If the Oracle database is down, the following error is returned:
5219: Temporary Oracle connection failure error in OCISessionBegin():
ORA-01034: ORACLE not available
5-21
Chapter 5
Dynamic Cache Groups
Note:
See DynamicLoadEnable, ttIsql or ttOptSetFlag in the Oracle TimesTen In-
Memory Database Reference.
You can also set connection attributes with the SQLSetConnectOption ODBC
function (ODBC 2.5) or the SQLSetConnectAttr function (ODBC 3.5). See
the Option Support for ODBC 2.5 SQLSetConnectOption and
SQLGetConnectOption and Attribute Support for ODBC 3.5
SQLSetConnectAttr and SQLGetConnectAttr sections in the Oracle
TimesTen In-Memory Database C Developer's Guide.
Note:
Examples for these guidelines are provided in Examples of Dynamic Load of
a Single Cache Instance.
5-22
Chapter 5
Dynamic Cache Groups
Dynamic load of a cache instance is available only for the following types of statements
issued on a cache table in a dynamic cache group:
• When an INSERT statement inserts values into any of the child tables of a cache instance
that does not currently exist in the TimesTen tables, the cache instance to which the new
row belongs dynamically loads. The insert operation for the new child row is propagated
to the cached Oracle Database table.
• SELECT, UPDATE, or DELETE statements require that the WHERE clause have the conditions
as stated in Dynamic Cache Groups.
The SELECT, UPDATE, or DELETE statements for which dynamic load is available must satisfy
the following conditions:
• If the statement contains a subquery, only the cache group with tables referenced in the
main query are considered for a dynamic load.
• If the statement references multiple tables of the cache group, the statement must
include an equality join condition between the primary keys and foreign keys for all parent
and child relationships.
• The statement cannot contain the UNION, INTERSECT, or MINUS set operators.
• The statement can reference non-cache tables.
• The statement can reference cache tables from only one dynamic cache group.
Dynamic load of a cache instance occurs when you set DynamicLoadEnable=1 and the
request passes the following rules:
• Dynamic load of a cache instance does not occur for a cache group if any table of the
cache group is specified more than once in any FROM clause.
• Only the conditions specified in the query are considered for dynamic load, which
excludes any derived conditions.
• If any cache group is referenced only in a subquery, it is not considered for a dynamic
load.
• When using an active standby pair replication scheme, dynamic load cannot occur in any
subscriber.
The following considerations can affect dynamic load:
• If tables within multiple cache groups or non-cache group tables are specified in the main
query, the join order influences if the cache instance is loaded. If during the processing of
the query, a dynamic load is possible and necessary to produce the query results, the
dynamic load occurs. However, if no rows are returned, then some or all of the cache
instances are not dynamically loaded.
• If a statement specifies more than the dynamic load condition on tables of a cache group,
the cache instance may be dynamically loaded even though the additional conditions are
not qualified for the statement.
You can use aging with a dynamic cache group. TimesTen supports two aging types, least
recently used (LRU) aging and time-based aging. By default, the data in a dynamic cache
group is subject to LRU aging. Time-based aging on a dynamic cache group overrides LRU
aging. If the cache group has a time-based aging policy defined, the timestamp in the root
table's row must be within the aging policy's lifetime in order for the cache instance to be
loaded.
Rows in a dynamic AWT cache group must be propagated to the Oracle database before
they become candidates for aging.
5-23
Chapter 5
Dynamic Cache Groups
You can use the ttAgingLRUConfig built-in procedure to override the default or current
LRU aging attribute settings for the aging cycle and TimesTen database space usage
thresholds. See Implementing Aging in a Cache Group for TimesTen Classic.
For example, the following data is in the sales.customer cached Oracle Database
table.
CUST_NUM REGION NAME ADDRESS
-------- ------- --------------- ---------------------------
1 West Frank Edwards 100 Pine St., Portland OR
2 East Angela Wilkins 356 Olive St., Boston MA
3 Midwest Stephen Johnson 7638 Walker Dr., Chicago IL
The following statement creates a dynamic AWT cache group new_customers that
caches the sales.customer, sales.orders, and sales.orderdetails tables:
CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH CACHE GROUP new_customers
FROM sales.customer
(cust_num NUMBER(6) NOT NULL,
region VARCHAR2(10),
name VARCHAR2(50),
address VARCHAR2(100),
PRIMARY KEY(cust_num)),
sales.orders
(ord_num NUMBER(10) NOT NULL,
cust_num NUMBER(6) NOT NULL,
when_placed DATE NOT NULL,
when_shipped DATE NOT NULL,
PRIMARY KEY(ord_num),
FOREIGN KEY(cust_num) REFERENCES sales.customer(cust_num)),
sales.orderdetails
(orderid NUMBER(10) NOT NULL,
itemid NUMBER(8) NOT NULL,
5-24
Chapter 5
Dynamic Cache Groups
The following SELECT statement with an equality condition on the primary key for the
sales.customer table results in a dynamic load of a single cache instance:
Command> SELECT * FROM sales.customer WHERE cust_num = 1;
< 1, West, Frank Edwards, 100 Pine St., Portland OR >
If you do not use an equality condition on the primary key and you do not configure for
dynamic load of multiple cache instances, then no dynamic load occurs for this example,
since it would result in multiple cache instances. See Dynamically Loading Multiple Cache
Instances for details on how to configure for this scenario.
Command> SELECT * FROM sales.customer WHERE cust_num IN (1,2);
The following example contains equality expressions on all of the primary key columns for a
primary key composite. The orderdetails table has a composite primary key of orderid and
itemid.
UPDATE sales.orderdetails SET quantity = 5 WHERE orderid=2280 AND itemid=663;
The following example shows an INSERT into the orders child table, which initiates a dynamic
load. However, if you tried to insert into the customer table, which is the parent, no dynamic
load occurs.
INSERT INTO orders VALUES(1,1, DATE '2012-01-25', DATE '2012-01-30');
The following UPDATE statement dynamically loads one cache instance from the cached
Oracle Database table into the TimesTen cache table, updates the instance in the cache
table, and then automatically propagates the update to the cached Oracle Database table:
Command> UPDATE sales.customer SET name = 'Angela Peterson' WHERE cust_num = 2;
Command> SELECT * FROM sales.customer;
< 1, West, Frank Edwards, 100 Pine St., Portland OR >
< 2, East, Angela Peterson, 356 Olive St., Boston MA >
The following is the updated data in the sales.customer cached Oracle Database table:
CUST_NUM REGION NAME ADDRESS
-------- ------- --------------- ---------------------------
1 West Frank Edwards 100 Pine St., Portland OR
2 East Angela Peterson 356 Olive St., Boston MA
3 Midwest Stephen Johnson 7638 Walker Dr., Chicago IL
The following DELETE statement dynamically loads one cache instance from the cached
Oracle Database table into the TimesTen cache table, deletes the instance from the cache
table, and then automatically propagates the delete to the cached Oracle Database table:
Command> DELETE FROM sales.customer WHERE cust_num = 3;
Command> SELECT * FROM sales.customer;
5-25
Chapter 5
Dynamic Cache Groups
The following is the updated data in the sales.customer cached Oracle Database
table.
CUST_NUM REGION NAME ADDRESS
-------- ------- --------------- ---------------------------
1 West Frank Edwards 100 Pine St., Portland OR
2 East Angela Peterson 356 Olive St., Boston MA
The following creates the dynamic AWT cache group and a unique index on the
dept_cg root table:
Command> CREATE DYNAMIC ASYNCHRONOUS WRITETHROUGH CACHE GROUP dept_cg
FROM departments
(department_id INT NOT NULL PRIMARY KEY,
department_name VARCHAR(10) NOT NULL,
technical_lead INT NOT NULL,
manager_id INT, location_id INT NOT NULL);
The following inserts three records into the departments table on the Oracle database:
Command> INSERT INTO departments
VALUES (1, 'acct', 1, 1, 100);
1 row inserted.
Command> INSERT INTO departments
VALUES (2, 'hr', 2, 2, 200);
1 row inserted.
Command> INSERT INTO departments
VALUES (3, 'owner', 3, NULL, 300);
1 row inserted.
Command> commit;
5-26
Chapter 5
Dynamic Cache Groups
The following sections describe methods for dynamically loading multiple cache instances:
• Dynamically Loading Multiple Cache Instances With Multiple Primary Keys
• Dynamically Loading Multiple Cache Instances Without Multiple Primary Keys
5-27
Chapter 5
Dynamic Cache Groups
OptimizerHint = TT_DynamicLoadMultiplePKs(1)
Note:
See Use Optimizer Hints to Modify the Execution Plan in the Oracle
TimesTen In-Memory Database Operations Guide, ttOptSetFlag in the
Oracle TimesTen In-Memory Database Reference and Optimizer Hints in the
Oracle TimesTen In-Memory Database SQL Reference.
The following examples use a cache group of products_cg that caches the Oracle
database products table.
CREATE DYNAMIC READONLY CACHE GROUP products_cg FROM
products(prod_type INT NOT NULL, prod_id BIGINT NOT NULL, prod_name
VARCHAR2(100),
prod_weight NUMBER, PRIMARY KEY(prod_type, prod_id));
The following examples demonstrate SELECT statements with a WHERE clause with
multiple primary keys that use conditions with either an IN operator and/or a single
value from an equality condition to return the name and weight of multiple products.
If the primary key of a root table is composed of two columns, x and y, the following
SELECT queries do result in a dynamic load:
• Both columns of the primary key use conditions with an equality condition resulting
in a single value.
(x=1 OR x=3) AND (y=2 OR y=4)
SELECT p.prod_name, p.prod_weight
FROM products p WHERE ((p.prod_type = 10 OR p.prod_type=100) AND
(p.prod_id = 20 OR p.prod_id = 200));
If the query tries to load cache instances that both exist and do not exist in the
database, then the entire dynamic load operation does not execute. The dynamic load
only executes if none of the cache instances requested already exist in the TimesTen
database.
5-28
Chapter 5
Dynamic Cache Groups
By default, TimesTen Classic does not dynamically load multiple cache instances for a single
table cache group when the SELECT statement has an arbitrary WHERE clause, unless you set
one of the following statement, transaction or connection level hints to 1.
• Statement level hint:
/*+TT_DynamicLoadRootTbl (1)*/
Note:
See Use Optimizer Hints to Modify the Execution Plan in the Oracle TimesTen In-
Memory Database Operations Guide, ttOptSetFlag in the Oracle TimesTen In-
Memory Database Reference and Optimizer Hints in the Oracle TimesTen In-
Memory Database SQL Reference.
Restrictions for dynamic load of multiple cache instances with arbitrary WHERE clause
In order for a dynamic load of multiple cache instances for a single table cache group, the
SELECT statement query must comply with the following:
• The results of the WHERE clause do not include any cache instances that currently exist in
the TimesTen database.
• The WHERE clause must be supported by the Oracle Database SQL syntax.
• Does not qualify for any other dynamic load condition.
• Does not use aggregation.
• No other table is referenced within the query. That is, the SELECT statement does not
specify any JOIN clauses or any subqueries embedded within the WHERE clause.
• Does not use the SELECT...FOR UPDATE clause or the INSERT … FOR SELECT clause.
Examples
These examples use the following cache group definition on the TimesTen database:
CREATE DYNAMIC READONLY CACHE GROUP cust_orders FROM
customers(cust_id BIGINT NOT NULL PRIMARY KEY, cust_name VARCHAR2(100),
cust_street VARCHAR2(200), cust_state VARCHAR2(2), cust_zip VARCHAR2(10))
WHERE (customers.cust_state = 'CA');
5-29
Chapter 5
Dynamic Cache Groups
None of the requested customers are in the cache group on the TimesTen database;
thus, all of the requested customers (and their orders) are dynamically loaded and
their names are returned by the query.
SELECT c.cust_name
FROM customers c
WHERE (c.cust_zip like '90210%');
<'Tom Hanks'>
<'Fred Rogers'>
Another customer and full data is inserted into the Oracle database:
INSERT INTO customers(cust_id, cust_name, cust_street, cust_state, cust_zip)
VALUES (300, 'Matthew Rhys', '2 Moscow Cir', 'CA', '90210');
On the TimesTen database, the following query is executed. Since the cache group
already has at least 1 row that satisfies the query, the dynamic load is not triggered.
Thus, only data that currently exists in the cache group are returned for the query.
SELECT c.cust_name
FROM customers c
WHERE (c.cust_zip like '90210%');
<'Tom Hanks'>
<'Fred Rogers'>
Call the ttOptSetFlag built-in procedure with the DynamicLoadErrorMode flag and
the optimizer value set to 0 to suppress error reporting when a statement does not
comply with dynamic load requirements.
5-30
Chapter 5
Determining the Number of Cache Instances Affected by an Operation
Passing through update operations to the Oracle database for processing is not
recommended when issued on cache tables in an AWT or SWT cache group. See
Considerations for Using Passthrough.
Note:
A transaction that contains operations that are replicated with RETURN TWOSAFE
cannot have a PassThrough setting greater than 0. If PassThrough is greater than 0,
an error is returned and the transaction must be rolled back.
When PassThrough is set to 0, 1, or 2, the following behavior occurs when a
dynamic load condition exists:
• A dynamic load can occur for a SELECT operation on cache tables in any
dynamic cache group type.
• A dynamic load for an INSERT, UPDATE, or DELETE operation can only occur on
cached tables with dynamic AWT or SWT cache groups.
See Dynamic Cache Groups.
5-31
Chapter 5
Setting a Passthrough Level
• PassThrough=0
• PassThrough=1
• PassThrough=2
• PassThrough=3
• Considerations for Using Passthrough
• Changing the Passthrough Level for a Connection or Transaction
• Automatic Passthrough of Dynamic Load to the Oracle Database
PassThrough=0
PassThrough=0 is the default setting and specifies that all SQL statements are to be
performed in the TimesTen database.
Figure 5-1 shows that Table A is updated on the TimesTen database. Table F cannot
be updated because it does not exist in TimesTen.
Application
Update Table A
Update Table F
PassThrough = 0
D Updatable
cache group
Oracle
database
B
A
F
E G
PassThrough=1
PassThrough=1 specifies that all DDL are run on TimesTen and most SQL statements
are run on TimesTen unless the tables referenced only exist on the Oracle database or
the SQL statement can only be parsed or understood on the Oracle database.
5-32
Chapter 5
Setting a Passthrough Level
Application
Update Table A
Update Table G
PassThrough = 1
TimesTen
B C Statement passed
database through to Oracle
D for execution
Updatable because table G
cache group does not exist in
TimesTen database
Oracle
database
B
A
F
E G
PassThrough=2
PassThrough=2 specifies that INSERT, UPDATE and DELETE statements performed on tables in
read-only cache groups or user managed cache groups with the READONLY cache table
attribute are passed through to the Oracle database.
5-33
Chapter 5
Setting a Passthrough Level
Passthrough=1 behavior applies for all other operations and cache group types.
Note:
You are responsible in preventing conflicts that may occur if you update the
same row in a cache table in TimesTen as another user updates the cached
Oracle Database table concurrently.
Figure 5-3 shows that updates to Table A and Table G in a read-only cache group are
passed through to the Oracle database.
Application
Update Table A
Update Table G
PassThrough = 2
TimesTen database
A
B C
INSERT, UPDATE and DELETE statements
D Read-only
are passed through to the Oracle
cache group database for read-only cache groups and
read-only cache tables. SELECT statements
are executed in TimesTen unless they
Oracle contain invalid TimesTen syntax or
reference tables that do not exist in TimesTen.
database
B
A
F
E G
PassThrough=3
PassThrough=3 specifies that all statements are passed through to the Oracle
database for processing.
Figure 5-4 shows that Table A is updated on the Oracle database for a read-only or
updatable cache group. A SELECT statement that references Table G is also passed
through to the Oracle database.
5-34
Chapter 5
Setting a Passthrough Level
Application
Update Table A
Select from Table G
PassThrough = 3
TimesTen database
A
Oracle
database
B
A
F
E G
5-35
Chapter 5
Setting a Passthrough Level
Note:
The passthrough feature uses OCI to communicate with the Oracle
database. The OCI diagnostic framework installs signal handlers that may
impact signal handling that you use in your application. You can disable OCI
signal handling by setting DIAG_SIGHANDLER_ENABLED=FALSE in the
sqlnet.ora file. Refer to Fault Diagnosability in OCI in Oracle Call Interface
Programmer's Guide.
You can also override the setting for a specific transaction by calling the ttOptSetFlag
built-in procedure with the PassThrough flag. The following procedure call sets the
passthrough level to 3:
CALL ttOptSetFlag('PassThrough', 3);
The PassThrough flag setting takes effect when a statement is prepared and it is the
setting that is used when the statement is performed even if the setting has changed
from the time the statement was prepared to when the statement is performed. After
the transaction has been committed or rolled back, the original connection setting
takes effect for all subsequently prepared statements.
In TimesTen Classic, for cache groups that are created without a WHERE clause, you
can limit the number of rows that are dynamically loaded from the Oracle database
into the cache instance. You can set the TT_DynamicPassthrough(N) optimizer hint,
where N is the limit to the number of rows allowed to load into the cache instance. If
any SELECT statement to the Oracle database would return a result with > N number of
rows, then the statement is passed through to the Oracle database and the results are
not loaded into the cache instance.
By default, the SELECT statement for a dynamic load of a cache group that qualifies for
dynamic load is executed on the TimesTen Classic database and all rows of the cache
instances are loaded. In addition, if you provide the optimizer hint and set N=0, then all
rows are loaded into the cache instance on the TimesTen Classic database.
This optimizer hint is supported as connection and statement level hints.
5-36
Chapter 5
Setting a Passthrough Level
The following example is a statement level optimizer hint requesting a dynamic passthrough
of a SELECT statement to the Oracle database if a dynamic load returns 1000 rows or more for
the SELECT statement.
SELECT /*+ TT_DynamicPassThrough(1000)*/ ...
5-37
6
Managing a Caching Environment
You can manage and monitor various aspects of a caching system such as cache groups and
the cache agent process.
• Checking the Status of Cache and Replication Agents
• Cache Agent and Replication Connection Recovery
• Managing a Cache Environment With Oracle Database Objects
• Monitoring Cache Groups
• Dropping Oracle Database Objects Used by Cache Groups With Autorefresh
• Impact on Cache Groups When Modifying the Oracle Database Schema
• Impact of Failed Autorefresh Operations on TimesTen Databases
• Managing the Cache Administration User's Tablespace
• Backing Up and Restoring a TimesTen Classic Database With Cache Groups
• Changing Cache User Names and Passwords
created,loaded-complete,open
Completely created elements: 6 (of 6)
Completely loaded elements: 6 (of 6)
Completely created replica sets: 3 (of 3)
Completely loaded replica sets: 3 (of 3)
Database database1 element level status as of Mon Dec 7 09:36:43 PST 2020
6-1
Chapter 6
Checking the Status of Cache and Replication Agents
Database database1 Replica Set status as of Mon Dec 7 09:36:43 PST 2020
Database database1 Data Space Group status as of Mon Dec 7 09:36:43 PST 2020
6-2
Chapter 6
Cache Agent and Replication Connection Recovery
The information displayed by the ttStatus utility include the following that pertains to
TimesTen for each TimesTen instance:
• The names of the cache agent process threads that are connected to the TimesTen
database
• The names of the replication agent process threads that are connected to the TimesTen
database
• Status on whether the cache agent is running
• Status on whether the replication agent is running
• The cache agent start policy
• The replication agent start policy
See ttStatus in Oracle TimesTen In-Memory Database Reference.
6-3
Chapter 6
Managing a Cache Environment With Oracle Database Objects
When a connection from the replication agent to the Oracle database fails, the
replication agent attempts to reconnect to the Oracle database after 120 seconds. If it
cannot reconnect after 120 seconds, the replication agent stops and does not restart.
If Fast Application Notification (FAN) is enabled on the Oracle database, the cache
agent and the replication agent receive immediate notification of connection failures. If
FAN is not enabled, the agents may wait until a TCP timeout occurs before becoming
aware that the connection has failed.
If the Oracle Real Application Clusters (Oracle RAC) is enable on the Oracle
database, along with FAN and Transparent Application Failover (TAF), then TAF
manages the connection to a new Oracle Database instance. See Using Cache in an
Oracle RAC Environment.
Note:
If you cache the same Oracle database table in a cache group on two
different TimesTen databases, we recommend that you use the same cache
administration user name on both TimesTen databases as the owner of the
cache table on each TimesTen database. See Caching the Same Oracle
Table on Two or More TimesTen Databases.
For each cache administration user, TimesTen creates the following Oracle Database
tables, where version is an internal TimesTen version number and object-ID is the ID
of the cached Oracle Database table:
6-4
Chapter 6
Managing a Cache Environment With Oracle Database Objects
6-5
Chapter 6
Monitoring Cache Groups
For each cache administration user, TimesTen creates the following Oracle Database
triggers, where version is an internal TimesTen version number, object-ID is the ID of
the cached Oracle Database table, and schema-ID is the ID of user who owns the
cached Oracle Database table:
6-6
Chapter 6
Monitoring Cache Groups
6-7
Chapter 6
Monitoring Cache Groups
6-8
Chapter 6
Monitoring Cache Groups
You can call the ttCacheAWTThresholdGet built-in procedure to determine the current
transaction log file threshold setting:
Command> CALL ttCacheAWTThresholdGet;
< 5 >
Command> exit
By default, DDL statements are not tracked. On TimesTen, you can enable tracking of DDL
statements issued on cached Oracle Database tables, call the ttCacheDDLTrackingConfig
built-in procedure as the TimesTen cache administration user. The following example enables
tracking of DDL statements issued on cached Oracle Database tables:
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL ttCacheDDLTrackingConfig('enable');
After generating the script, use SQL*Plus to run the script as the sys user.
The following example creates DDL tracking table and trigger when Oracle Database objects
are manually created. In this example, the SQL*Plus script generated by the ttIsql utility
cachesqlget command is saved to the /tmp/trackddl.sql file. The owner of the cached
Oracle Database table sales is passed as an argument to the command.
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> cachesqlget ORACLE_DDL_TRACKING sales INSTALL /tmp/trackddl.sql;
Command> exit
6-9
Chapter 6
Dropping Oracle Database Objects Used by Cache Groups With Autorefresh
The information returned for each Oracle Database user that owns cached Oracle
Database tables includes the name of the DDL tracking table, the name of its
corresponding DDL trigger, the name of the user that the DDL trigger is associated
with, and the number of cache groups that cache a table owned by the user
associated with the DDL trigger.
If a cache group contains more than one cache table, each cache table owned by the
user associated with the DDL trigger contributes to the cache group count.
See SQL*Plus Scripts for Cache in this book and ttCacheDDLTrackingConfig in Oracle
TimesTen In-Memory Database Reference.
6-10
Chapter 6
Dropping Oracle Database Objects Used by Cache Groups With Autorefresh
Oracle database objects used to implement autorefresh operations also continue to exist in
the Oracle database when a TimesTen database is no longer being used but still contains
cache groups with autorefresh. Rows continue to accumulate in the change log tables. This
impacts autorefresh performance on other TimesTen databases. Therefore, it is desirable to
drop these Oracle database objects associated with the unavailable or abandoned TimesTen
database.
• When using TimesTen Classic, run the timesten_home/install/oraclescripts/
cacheCleanUp.sql SQL*Plus script as the Oracle cache administration user to drop the
Oracle database objects used to implement autorefresh operations. The host name of the
TimesTen Classic system and the TimesTen database (including its path) are passed as
arguments to the cacheCleanUp.sql script.
You can run the cacheInfo.sql script as the Oracle cache administration user to
determine the host and database names.
• In TimesTen Scaleout, run the timesten_home/install/oraclescripts/
scaleoutCacheCleanUp.sql SQL*Plus script as the Oracle cache administration user to
drop the Oracle Database objects used to implement autorefresh operations. The grid
name and the TimesTen database name are passed as arguments to the
scaleoutCacheCleanUp.sql script.
You can run the cacheInfo.sql script as the Oracle cache administration user to
determine the grid and database names.
The cacheInfo.sql script can also be used to determine whether any objects used to
implement autorefresh operations exist in the Oracle database.
The following example demonstrates how to drop Oracle database objects for cache groups
with autorefresh. In this example, the TimesTen database contains one read-only cache
group customer_orders with cache tables sales.customer and sales.orders.
This example uses the cacheCleanUp.sql script for a TimesTen Classic system. It drops the
change log tables and triggers associated with the two cache tables. The
scaleoutCacheCleanup.sql script runs in the same manner for TimesTen Scaleout, except
that it requires the grid name and database name as input parameters.
% cd timesten_home/install/oraclescripts
% sqlplus cacheadmin/orapwd
SQL> @cacheCleanUp "sys1" "/users/OracleCache/ttcache"
*****************************OUTPUT**************************************
Performing cleanup for object_id: 69959 which belongs to table : CUSTOMER
Executing: delete from tt_07_agent_status where host = sys1 and datastore =
/users/OracleCache/ttcache and object_id = 69959
Executing: drop table tt_07_69959_L
Executing: drop trigger tt_07_69959_T
Executing: delete from tt_07_user_count where object_id = object_id1
Performing cleanup for object_id: 69966 which belongs to table : ORDERS
Executing: delete from tt_07_agent_status where host = sys1 and datastore =
/users/OracleCache/ttcache and object_id = 69966
Executing: drop table tt_07_69966_L
Executing: drop trigger tt_07_69966_T
Executing: delete from tt_07_user_count where object_id = object_id1
**************************************************************************
6-11
Chapter 6
Impact on Cache Groups When Modifying the Oracle Database Schema
6-12
Chapter 6
Impact of Failed Autorefresh Operations on TimesTen Databases
periodically deletes rows in the change log tables that have been applied to the cache tables.
An Oracle Database table cannot be cached in more than one cache group within a
TimesTen database. However, an Oracle Database table can be cached in more than one
TimesTen database. This results in an Oracle Database table corresponding to multiple
TimesTen cache tables. If updates on cached Oracle Database tables are not being
automatically refreshed into all of their corresponding cache tables because the cache agent
is not running on one or more of the TimesTen databases that the Oracle Database tables are
cached in, rows in their change log tables are not deleted by default. The cache agent may
not be running on a particular TimesTen database because the agent was either stopped or
never started, the database was destroyed, or the TimesTen instance is down. As a result,
rows accumulate in the change log tables and degrade the performance of autorefresh
operations on cache tables in TimesTen databases where the cache agent is running. This
can also cause the Oracle cache administration user's tablespace to fill up.
For example, if a single Oracle Database table is cached by two or more TimesTen
databases where one of the TimesTen databases is unable to connect to the Oracle
database, then autorefresh for the disconnected TimesTen database is not performed.
Instead, the records in the change log table accumulate (so that the disconnected TimesTen
database can catch up once a connection to the Oracle database is established). If the
AgentTimeout parameter is set to 0 (the default), then all change log records are kept
indefinitely until they have been applied to all its cache tables. The change log records of the
other TimesTen databases are not purged even though the transaction logs are already
applied to the local TimesTen database. Alternatively, you can set the AgentTimeout
parameter to define a specific timeout to wait before purging the saved change log records
and stop the accumulation of these change log records.
The following criteria must be met in order for TimesTen to delete rows in the change log
tables when the cache agent is not running on a TimesTen database and a cache agent
timeout is set:
• Oracle Database tables are cached in cache groups with autorefresh enabled within
more than one TimesTen database.
• The cache agent is running on at least one of the TimesTen databases but is not running
on at least another database.
• Rows in the change log tables have been applied to the cache tables on all TimesTen
databases where the cache agent is running.
• For those databases where the cache agent is not running, the agent process has been
down for a period of time that exceeds the cache agent timeout.
To set the cache agent timeout and prevent rows from accumulating in the change log tables,
set the AgentTimeout parameter with the ttCacheConfig built-in procedure as the TimesTen
cache administration user from any of the TimesTen databases that cache data from the
Oracle database. Pass the AgentTimeout string to the Param parameter and the timeout
setting as a numeric string to the Value parameter. Do not pass in any values to the tblOwner
and tblName parameters as they are not applicable to setting a cache agent timeout.
In the following example, the cache agent timeout is set to 900 seconds (15 minutes):
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL ttCacheConfig('AgentTimeout',,,'900');
To determine the current cache agent timeout setting, call ttCacheConfig passing only the
AgentTimeout string to the Param parameter:
6-13
Chapter 6
Impact of Failed Autorefresh Operations on TimesTen Databases
The default cache agent timeout setting is 0, which means that all change log records
are kept indefinitely until they have been applied to all its cache tables. If you set the
cache agent timeout to a value between 1 and 600 seconds, the timeout is set to 600
seconds. The cache agent timeout applies to all TimesTen databases that cache data
from the same Oracle database and have the same Oracle cache administration user
name setting.
When determining a proper cache agent timeout setting, consider the time it takes to
load the TimesTen database into memory, the time to start the cache agent process,
potential duration of network outages, and anticipated duration of planned
maintenance activities.
Each TimesTen database, and all of its cache groups have an autorefresh status to
determine whether any deleted rows from the change log tables were not applied to
the cache tables in the cache groups. If rows were deleted from the change log tables
and not applied to some cache tables because the cache agent on the database was
down for a period of time that exceeded the cache agent timeout, those cache tables
are no longer synchronized with the cached Oracle Database tables. Subsequent
updates on the cached Oracle Database tables are not automatically refreshed into
the cache tables until the accompanying cache group is recovered.
The following are the possible statuses for a cache group with autorefresh:
• ok: All of the deleted rows from the change log tables were applied to its cache
tables. Incremental autorefresh operations continue to occur on the cache group.
• disabled or dead: Some of the deleted rows from the change log tables were not
applied to its cache tables so the cache tables are not synchronized with the
cached Oracle Database tables. Autorefresh operations have ceased on the cache
group and do not resume until the cache group has been recovered.
• recovering: The cache group is being recovered. Once recovery completes, the
cache tables are synchronized with the cached Oracle Database tables, the cache
group's autorefresh status is set to ok, and incremental autorefresh operations
resume on the cache group.
The following are the possible autorefresh statuses for a TimesTen database:
• alive: All of its cache groups with autorefresh have an autorefresh status of OK.
• dead: All of its cache groups with autorefresh have an autorefresh status of dead.
• recovering: At least one of its cache groups with autorefresh have an autorefresh
status of recovering.
If the cache agent on a TimesTen database is down for a period of time that exceeds
the cache agent timeout, the autorefresh status of the database is set to dead. Also,
the autorefresh status of all cache groups with autorefresh within that database are set
to dead.
In the following example, the autorefresh status of the database is alive and the
autorefresh status of the cacheadmin.customer_orders read-only cache group is ok:
6-14
Chapter 6
Impact of Failed Autorefresh Operations on TimesTen Databases
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL ttCacheDbCgStatus('cacheadmin','customer_orders');
< alive, ok >
To view only the autorefresh status of the database and not of a particular cache group, call
ttCacheDbCgStatus without any parameters:
Command> CALL ttCacheDbCgStatus;
< dead, <NULL> >
If the autorefresh status of a cache group is ok, its cache tables are being automatically
refreshed based on its autorefresh interval. If the autorefresh status of a database is alive,
the autorefresh status of all its cache groups with autorefresh are ok.
If the autorefresh status of a cache group is disabled or dead, its cache tables are no longer
being automatically refreshed when updates are committed on the cached Oracle Database
tables. The cache group must be recovered in order to resynchronize the cache tables with
the cached Oracle Database tables. See Disabling Full Autorefresh for Cache Groups.
You can configure a recovery method for cache groups whose autorefresh status is dead.
Call the ttCacheConfig built-in procedure as the TimesTen cache administration user from
any of the TimesTen databases that cache data from the Oracle database. Pass the
DeadDbRecovery string to the Param parameter and the recovery method as a string to the
Value parameter. Do not pass in any values to the tblOwner and tblName parameters as they
are not applicable to setting a recovery method for dead cache groups.
The following are the valid recovery methods:
• Normal: When the cache agent starts, a full autorefresh operation is performed on cache
groups whose autorefresh status is dead in order to recover those cache groups. This is
the default recovery method. However, if you set the DisableFullAutorefresh cache
configuration parameter to 1, then the DeadDbRecovery cache configuration parameter
automatically changes to Manual.
• Manual: For each static cache group whose autorefresh status is dead, a REFRESH CACHE
GROUP statement must be issued in order to recover these cache groups after the cache
agent starts.
For each dynamic cache group whose autorefresh status is dead, a REFRESH CACHE
GROUP or UNLOAD CACHE GROUP statement must be issued in order to recover these cache
groups after the cache agent starts.
• None: Cache groups whose autorefresh status is dead must be dropped and then re-
created after the cache agent starts in order to recover them.
In the following example, the recovery method is set to Manual for cache groups whose
autorefresh status is dead:
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL ttCacheConfig('DeadDbRecovery',,,'Manual');
To determine the current recovery method for dead cache groups, call ttCacheConfig
passing only the DeadDbRecovery string to the Param parameter:
Command> CALL ttCacheConfig('DeadDbRecovery');
< DeadDbRecovery, <NULL>, <NULL>, manual >
6-15
Chapter 6
Managing the Cache Administration User's Tablespace
The recovery method applies to all cache groups with autorefresh in all TimesTen
databases that cache data from the same Oracle database and have the same Oracle
cache administration user name setting.
When a cache group begins the recovery process, its autorefresh status is changed
from dead to recovering, and the status of the accompanying TimesTen database is
changed to recovering, if it is currently dead.
After the cache group has been recovered, its autorefresh status is changed from
recovering to ok. Once all cache groups have been recovered and their autorefresh
statuses are ok, the status of the accompanying TimesTen database is changed from
recovering to alive.
6-16
Chapter 6
Managing the Cache Administration User's Tablespace
Note:
Messages are logged to the user and support error logs. For details, see Error,
Warning, and Informational Messages in the Oracle TimesTen In-Memory Database
Operations Guide.
To set the fragmentation threshold, call the ttCacheConfig built-in procedure as the
TimesTen cache administration user from any of the TimesTen databases that cache data
from the Oracle database. Pass the AutoRefreshLogFragmentationWarningPCT string to the
Param parameter and the threshold setting as a numeric string to the Value parameter.
To set the time interval for how often to calculate the fragmentation percentage, call the
ttCacheConfig built-in procedure as the TimesTen cache administration user from any of the
TimesTen databases that cache data from the Oracle database. Pass the
AutorefreshLogMonitorInterval string to the Param parameter and the time interval (in
seconds) as a numeric string to the Value parameter.
Note:
Do not pass in any values to the tblOwner and tblName parameters as they are not
applicable to setting the fragmentation threshold or the time interval for the
threshold calculation.
In the following example, the fragmentation threshold is set to 50% and the time interval for
calculating the fragmentation threshold is set to 3600 seconds:
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL ttCacheConfig('AutoRefreshLogFragmentationWarningPCT',,,'50');
< AutoRefreshLogFragmentationWarningPCT, <NULL>, <NULL>, 50 >
1 row found.
Command> CALL ttCacheConfig('AutorefreshLogMonitorInterval',,,'3600');
< AutorefreshLogMonitorInterval, <NULL>, <NULL>, 3600 >
1 row found.
To determine the current fragmentation threshold setting, call ttCacheConfig passing the
AutoRefreshLogFragmentationWarningPCT string to the Param parameter:
Command> CALL ttCacheConfig('AutoRefreshLogFragmentationWarningPCT');
< AutoRefreshLogFragmentationWarningPCT, <NULL>, <NULL>, 50 >
6-17
Chapter 6
Managing the Cache Administration User's Tablespace
Note:
Do not pass in any values to the tblOwner and tblName parameters as they
are not applicable to setting the defragmentation action.
• Manual. This is the default. No action is taken to defragment the change log tables.
Any defragmentation must be performed manually by running the
ttCacheAutoRefreshLogDeFrag built-in procedure. See Manually Defragmenting
the Change Log Tables for Cache Groups With Autorefresh.
• Compact: TimesTen defragments the change log tables.
• CompactAndReclaim: TimesTen defragments the change log tables and reclaims
the space.
Note:
When reclaiming space, the change log table is briefly locked, which
temporarily suspends writing into the base table.
In the following example, the action is set to CompactAndReclaim so that when the
fragmentation ratio falls below the threshold, TimesTen defragments the change log
tables and reclaims the space:
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL
ttCacheConfig('AutoRefreshLogDeFragmentAction',,,'CompactAndReclaim');
< AutoRefreshLogDeFragmentAction, <NULL>, <NULL>, compactandreclaim >
1 row found.
You can discover the fragmentation percentage of the tablespace and when the last
defragmentation operation was performed with the following returned columns from
the ttCacheAutorefreshStatsGet built-in procedure:
6-18
Chapter 6
Managing the Cache Administration User's Tablespace
Manually Defragmenting the Change Log Tables for Cache Groups With Autorefresh
To manually initiate a defragmentation of the change log tables, call the
ttCacheAutoRefreshLogDeFrag built-in procedure as the TimesTen cache administration user
from any of the TimesTen databases that cache data from the Oracle database.
Pass in one of the following strings as the parameter:
• Compact: Defragment the change log tables.
• CompactAndReclaim: Defragment the change log tables and reclaim the space.
Note:
When reclaiming space, the change log table is briefly locked, which
temporarily suspends writing into the base table.
The following example manually defragments the change log tables with the
ttCacheAutoRefreshLogDeFrag built-in procedure providing the CompactAndReclaim option:
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL ttCacheAutoRefreshLogDeFrag('CompactAndReclaim');
6-19
Chapter 6
Managing the Cache Administration User's Tablespace
To determine the current Oracle cache administration user's tablespace usage warning
threshold, call ttCacheConfig passing only the AutoRefreshLogTblSpaceUsagePCT
string to the Param parameter:
Command> CALL ttCacheConfig('AutoRefreshLogTblSpaceUsagePCT');
< AutoRefreshLogTblSpaceUsagePCT, <NULL>, <NULL>, 80 >
The default Oracle cache administration user's tablespace usage warning threshold is
0 percent which means that no warning is returned to the application regardless of the
tablespace usage. The Oracle cache administration user's tablespace usage warning
threshold applies to all TimesTen databases that cache tables from the same Oracle
database and have the same Oracle cache administration user name setting.
See ttCacheConfig in the Oracle TimesTen In-Memory Database Reference.
Rather than TimesTen returning an error to the Oracle Database application when the
Oracle cache administration user's tablespace is full, you can configure TimesTen to
delete existing rows from the change log tables to make space for new rows when an
update operation is issued on a particular cached Oracle Database table. If some of
the deleted change log table rows have not been applied to the cache tables, a full
autorefresh operation is performed on those cache tables in each TimesTen database
that contains the tables upon the next autorefresh cycle.
Call the ttCacheConfig built-in procedure as the TimesTen cache administration user
from any of the TimesTen databases that cache tables from the Oracle database. Pass
the TblSpaceFullRecovery string to the Param parameter, the owner and name of the
cached Oracle Database table to the tblOwner and tblName parameters, respectively,
on which you want to configure an action to take if the Oracle cache administration
user's tablespace becomes full, and the action itself as a string to the Value
parameter.
The following are the valid actions:
• None: Return an Oracle Database error to the application when an update
operation is issued on the cached Oracle Database table. This is the default
action.
• Reload: Delete rows from the change log table and perform a full autorefresh
operation on the cache table upon the next autorefresh cycle when an update
operation is issued on the cached Oracle Database table.
The following example configures an action when the Oracle cache administration
user's tablespace becomes full. In this example, rows are deleted from the change log
table and a full autorefresh operation is performed on the cache table upon the next
autorefresh cycle when an update operation is issued on the sales.customer cached
Oracle Database table while the Oracle cache administration user's tablespace is full:
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL ttCacheConfig('TblSpaceFullRecovery','sales','customer','Reload');
6-20
Chapter 6
Backing Up and Restoring a TimesTen Classic Database With Cache Groups
tablespace is full, call ttCacheConfig passing only the TblSpaceFullRecovery string to the
Param parameter, and the owner and name of the cached Oracle Database table to the
tblOwner and tblName parameters, respectively:
Command> CALL ttCacheConfig('TblSpaceFullRecovery','sales','customer');
< TblSpaceFullRecovery, SALES, CUSTOMER, reload >
The action to take when update operations are issued on a cached Oracle Database table
while the Oracle cache administration user's tablespace is full applies to all TimesTen
databases that cache tables from the same Oracle database and have the same Oracle
cache administration user name setting.
See ttCacheConfig in the Oracle TimesTen In-Memory Database Reference.
• If the restored database connects to the same backend Oracle database, then use the
ttBackup and ttRestore utilities, then drop and recreate all cache groups in the restored
TimesTen database. If they are static cache groups, you may be required to reload them.
For dynamic cache groups, the reload is optional as data is pulled in from the Oracle
database as it is referenced.
Note:
If another TimesTen database is used to connect to the original backend Oracle
database (and now no longer connects) and if all cache groups in the TimesTen
database were not cleanly dropped, then run the cacheCleanUp.sql SQL*Plus
script against the original Oracle database to remove all leftover objects.
Specify the host and path for the original TimesTen database.
See SQL*Plus Scripts for Cache.
• If the restored database connects to a different backend Oracle database than what it
had originally connected with, then perform one of the following:
– Backing Up and Restoring Using the ttBackup and ttRestore Utilities
– Backing Up and Restoring TimesTen Classic Database With the ttMigrate Utility
6-21
Chapter 6
Backing Up and Restoring a TimesTen Classic Database With Cache Groups
Note:
See ttBackup and ttRestore in the Oracle TimesTen In-Memory Database
Reference.
If the restored database connects to a different backend Oracle database than what it
had originally connected with and you want to use the ttBackup and ttRestore utilities
to backup and restore your database, then perform the following:
1. Run the ttBackup utility command to backup the database and its objects into a
binary file. For example, to backup the cache1 database using the /tmp/dump
directory for temporary storage:
% ttBackup -dir /tmp/dump -connstr "DSN=cache1"
3. (Optional) Drop all cache groups from the TimesTen database. Since the database
still exists with its cache groups, TimesTen recommends that you drop the cache
groups.
Command> DROP CACHE GROUP readcache;
Command> exit;
Disconnecting...
Done.
*****************************OUTPUT**************************************
Performing cleanup for object_id: 69959 which belongs to table : CUSTOMER
Executing: delete from tt_07_agent_status where host = sys1 and datastore =
/users/OracleCache/cache1 and object_id = 69959
Executing: drop table tt_07_69959_L
Executing: drop trigger tt_07_69959_T
Executing: delete from tt_07_user_count where object_id = object_id1
Performing cleanup for object_id: 69966 which belongs to table : ORDERS
Executing: delete from tt_07_agent_status where host = sys1 and datastore =
/users/OracleCache/cache1 and object_id = 69966
Executing: drop table tt_07_69966_L
Executing: drop trigger tt_07_69966_T
6-22
Chapter 6
Backing Up and Restoring a TimesTen Classic Database With Cache Groups
6. Restore the database with the ttRestore utility and then delete the temporary directory.
% ttRestore -dir /tmp/dump -connstr "DSN=cache1"
Restore started ...
Restore complete
% rm -r /tmp/dump
7. In order to re-synchronize the data within the cache groups, you must drop and recreate
the cache groups:
a. Connect to the TimesTen database.
b. Drop the cache groups that were restored with the ttRestore utility. Because the
data is out of sync, you may see errors.
c. Specify the Oracle cache administration user name and password with the
ttCacheUidPwdSet built-in procedure.
d. Start the cache agent.
e. Recreate and, if required, reload the cache groups.
% ttIsql -connstr "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Note:
If the restored TimesTen database is not able to connect to any backend Oracle
database, then TimesTen cannot autorefresh the data for the read-only cache
groups.
6-23
Chapter 6
Backing Up and Restoring a TimesTen Classic Database With Cache Groups
Note:
See Backup, Restore, and Migrate Data in TimesTen Classic in the Oracle
TimesTen In-Memory Database Installation, Migration, and Upgrade Guide
and ttMigrate in the Oracle TimesTen In-Memory Database Reference.
If the restored database connects to a different backend Oracle database than what it
had originally connected with and you want to use the ttMigrate utility for backing up
and restoring the database, then perform the following:
1. Stop the cache agent.
% ttIsql -connstr "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> call ttCacheStop;
Command> exit
Disconnecting...
Done.
2. Run the ttMigrate -c utility command to save the database and its objects into a
binary file.
% ttMigrate -c "DSN=cache1" cache1.ttm
...
Saving user CACHEADMIN
User successfully saved.
3. (Optional) Drop all cache groups from the TimesTen database. Since the database
still exists with its cache groups, TimesTen recommends that you drop the cache
groups. When you drop all cache groups before destroying the TimesTen
database, all metadata on the Oracle Database for these cache groups is deleted.
However, if you use the cacheCleanup.sql script in a future step, this script
deletes the metadata on the Oracle Database.
You may see errors reported, which can be ignored.
Command> DROP CACHE GROUP readcache;
Command> exit
Disconnecting...
Done.
5. Clean up objects on the Oracle database: If you did not drop that cache groups in
an earlier step, you can run the timesten_home/install/oraclescripts/
cacheCleanUp.sql SQL*Plus script as the Oracle cache administration user to
6-24
Chapter 6
Backing Up and Restoring a TimesTen Classic Database With Cache Groups
drop the Oracle Database objects used to implement autorefresh operations. The host
name of the TimesTen Classic system and the TimesTen database (including its path) are
passed as arguments to the cacheCleanUp.sql script.
You can run the cacheInfo.sql script as the Oracle cache administration user to
determine the host and database names.
% cd timesten_home/install/oraclescripts
% sqlplus cacheadmin/orapwd
SQL> @cacheCleanUp "sys1" "/users/OracleCache/cache1"
*****************************OUTPUT**************************************
Performing cleanup for object_id: 69959 which belongs to table : CUSTOMER
Executing: delete from tt_05_agent_status where host = sys1 and datastore =
/users/OracleCache/cache1 and object_id = 69959
Executing: drop table tt_05_69959_L
Executing: drop trigger tt_05_69959_T
Executing: delete from tt_05_user_count where object_id = object_id1
Performing cleanup for object_id: 69966 which belongs to table : ORDERS
Executing: delete from tt_05_agent_status where host = sys1 and datastore =
/users/OracleCache/cache1 and object_id = 69966
Executing: drop table tt_05_69966_L
Executing: drop trigger tt_05_69966_T
Executing: delete from tt_05_user_count where object_id = object_id1
**************************************************************************
Note:
Depending on which TimesTen Classic release you are migrating from, the
users and privileges may or may not be migrated. See ttMigrate in the
Oracle TimesTen In-Memory Database Reference.
c. Specify the Oracle cache administrator user name and password with the
ttCacheUidPwdSet built-in procedure.
% ttIsql cache1
Command> CREATE USER cacheadmin IDENTIFIED BY timesten;
User created.
Command> exit
Disconnecting...
Done.
6-25
Chapter 6
Changing Cache User Names and Passwords
7. Restore the database from the saved binary file with the ttMigrate -r utility
command.
% ttMigrate -r -relaxedUpgrade -cacheuid cacheadmin -cachepwd orapwd
-connstr "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
cache1.ttm
...
Restoring table CACHEADMIN.READTAB
Restoring rows...
2/2 rows restored.
Table successfully restored.
8. Connect to the restored database and reset the cache autorefresh state:
a. Connect to the TimesTen database with ttIsql.
b. Start the cache agent.
c. Alter the cache groups to set autorefresh state to ON.
% ttIsql -connstr
"DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> call ttCacheStart;
Command> ALTER CACHE GROUP readcache SET AUTOREFRESH STATE ON;
Note:
If the restored TimesTen database is not able to connect to any backend
Oracle database, then TimesTen cannot autorefresh the data for the read-
only cache groups.
Note:
Passwords for both the TimesTen cache administration user and its
companion Oracle cache administration user can be changed at any
time.
The name for the TimesTen cache administration user must be the same
as its companion Oracle cache administration user; however, the
passwords may be different. See Create the TimesTen Users.
6-26
Chapter 6
Changing Cache User Names and Passwords
a. On the TimesTen database, if you want to modify the password of the TimesTen
cache administration user, then use the ALTER USER statement on the active master.
Command> ALTER USER cacheadmin IDENTIFIED BY newpwd;
b. On the back-end Oracle database, you can modify the companion Oracle cache
administration user password with the ALTER USER statement. If you are working on
TimesTen, you can use Passthrough 3 to run this directly on the Oracle database.
Command> passthrough 3;
Command> ALTER USER cacheadmin IDENTIFIED BY newpwd;
Note:
If you have modified the password for the companion Oracle cache
administration user, reconnect to the TimesTen database as the TimesTen
cache administration user providing passwords for the TimesTen cache
administration user and its companion Oracle cache administration user.
c. If you want to change the TimesTen cache administration user, you must first drop all
cache groups that the TimesTen cache administration user owns before dropping the
existing user and creating a new user. The Oracle cache administration user name
can only be changed when there are no cache groups on the TimesTen database.
Note:
Alternatively, if you want to use a different user as the TimesTen cache
administration user, ensure that it has the correct privileges and a
companion Oracle cache administration user with the correct privileges.
In addition, since the TimesTen cache administration user must have a companion
Oracle cache administration user with the same name, you must either:
• Drop all tables owned by the current companion Oracle cache administration
user, drop the user, and then re-create it with the same name as the new
TimesTen cache administration user.
• Choose another Oracle user that has the same name as the TimesTen cache
administration user and provides the same functionality.
See Create the TimesTen Users.
d. On TimesTen Classic, if the TimesTen cache administration user name or password
are defined in the sys.odbc.ini (or odbc.ini) file, update the new TimesTen cache
administration user name or password in the sys.odbc.ini (or odbc.ini) file on both
the active and standby masters.
2. If you want to modify the Oracle cache administration user or its password, perform the
following:
a. On the back-end Oracle database, you can modify the Oracle cache administration
password with the ALTER USER statement. The password of the Oracle cache
administration user can be changed at any time.
6-27
Chapter 6
Changing Cache User Names and Passwords
If you are working on TimesTen, you can use Passthrough 3 to run this
directly on the Oracle database.
Command> passthrough 3;
Command> ALTER USER cacheadmin IDENTIFIED BY newpwd;
b. If you want to change the Oracle cache administration user, you must first drop
all cache groups on the TimesTen database that the Oracle cache
administration user manages before you can drop the Oracle cache
administration user on the Oracle database and create a new user. Dropping
the cache groups on TimesTen removes all metadata associated with those
cache groups.
When you create a new Oracle cache administration user on the Oracle
database, you must follow the same instructions for creating a Oracle cache
administration user that are provided in the Create the Oracle Database Users
and Default Tablespace.
c. Set the new user name or password for the Oracle cache administration user.
• On TimesTen Classic, run the ttCacheUidPwdSet built-in procedure on the
active master database.
Note:
See Set the Cache Administration User Name and Password.
Note:
See Set the Cache Administration User Name and Password in
the TimesTen Database in the Oracle TimesTen In-Memory
Database Cache Guide.
6-28
7
Cache Performance
The following sections contain information about cache performance.
Note:
7-1
Chapter 7
Dynamic Load Performance
7-2
Chapter 7
Dynamic Load Performance
Note:
If an application runs a higher than expected number of dynamic load requests and
performance is critical, then you might consider either:
• Removing or minimizing passthrough statements with DDL or DML statements
(which can slow down performance) from any application using the cache
connection pool.
• Maintaining a completely separate client connection directly to the Oracle
Database to run its SQL directly against the Oracle database, rather than using
passthrough statements to run SQL indirectly through TimesTen.
To decide whether to use the cache connection pool, evaluate if any applications request a
high number of dynamic load operations from the Oracle database (resulting in too many
open client connections to the Oracle database).
The following sections describe how to use the cache connection pool for your dynamic read-
only cache groups:
• Enable the Cache Connection Pool
• Size the Cache Connection Pool
• Use the ChildServer Connection Attribute to Identify a Child Server Process
• Dynamically Applying Cache Connection Pool Sizing Modifications
• Example Demonstrating Management of the Cache Connection Pool
• Limiting the Number of Connections to the Oracle Database
• Restrictions for the Cache Connection Pool
Note:
The cache connection pool can only be initiated from client-server applications
(using multithreaded mode) and is used only for dynamic loads initiated for dynamic
read-only cache groups.
To enable client/server connection requests to use the cache connection pool, an application
must specify the following connection attributes when connecting.
• MaxConnsPerServer connection attribute: This connection attribute sets the maximum
number of client/server connections that can be created for each child server process.
7-3
Chapter 7
Dynamic Load Performance
When the value is set to > 1, each TimesTen child server can handle multiple client
connections where each client/server connection is multithreaded. You can only
use the cache connection pool with a multithreaded client/server connection.
When MaxConnsPerServer connection attribute is set to 1, TimesTen creates one
single-threaded client/server connection for each child server process.
• ServersPerDSN connection attribute: Value designates the number of child server
processes to spawn for the TimesTen server. Default is 1.
Each new incoming connection spawns a new child server process up to the value
specified by the ServersPerDSN connection attribute. When the maximum number
of child server processes is reached, the existing child server processes handle
multiple connections (up to the number specified in MaxConnsPerServer) in a
round-robin method. That is, if you specify ServersPerDSN = 2 and
MaxConnsPerServer = 3, then the first two connections would spawn two child
server processes. The third through the sixth connections would be handled by
these child server processes, where each child server process would service
every other connection.
Once all of the child server processes have the maximum allowed number of
connections, the next incoming connection starts a new set of child server
processes.
The ServersPerDSN and MaxConnsPerServer connection attributes are used to
designate how to distribute connections across multiple child server processes.
• UseCacheConnPool connection attribute: Must be enabled (set to 2) to use the
cache connection pool. When the UseCacheConnPool connection attribute is
enabled, the cache connection pool is created and used for dynamic load
operations initiated by multithreaded client/server connections. If the
UseCacheConnPool connection attribute is disabled (set to 0), then the cache
connection pool is not created and the dynamic load operations perform using the
existing behavior. See UseCacheConnPool in the Oracle TimesTen In-Memory
Database Reference.
Note:
You may also want to limit the number of connections to the Oracle
database. See Limiting the Number of Connections to the Oracle Database.
The following example specifies connection attributes for the cache connection pool in
the DSN definition:
The cache1 DSN definition in the sys.odbc.ini file specifies UseCacheConnPool=2,
ServersPerDSN=2 and MaxConnsPerServer=3.
[cache1]
DataStore=/users/OracleCache/database1
PermSize=64
OracleNetServiceName=oracledb
DatabaseCharacterSet=AL32UTF8
UseCacheConnPool=2
ServersPerDSN=2
MaxConnsPerServer=3
7-4
Chapter 7
Dynamic Load Performance
Alternatively, you can specify both of the connection attributes on the command line when
connecting from the application.
ttIsql "DSN=cache1; OracleNetServiceName=oracledb; UseCacheConnPool=2;
ServersPerDSN=2; MaxConnsPerServer=3"
Note:
See the MaxConnsPerServer, ServersPerDSN, and UseCacheConnPool sections
in the Oracle TimesTen In-Memory Database Reference.
The ttCacheConnPoolSet built-in procedure saves the values of these parameters in the
Oracle database, which are then used as the default values when restarting the TimesTen
server. Once applied to each TimesTen server, the values specified are used for the cache
connection pool across all client/server applications for a TimesTen database.
If you want to modify these values after the TimesTen server starts, you can change the
cache connection pool sizing parameters on the Oracle database using the
ttCacheConnPoolSet built-in procedure. After which, you can re-initialize the TimesTen server
by either:
• Restarting the TimesTen server to re-initialize the server (and all child server processes)
with the new sizing parameters.
• Dynamically re-initializing each TimesTen server with the cache connection pool
parameters saved on the Oracle database with the ttCacheConnPoolApply built-in
procedure. See Dynamically Applying Cache Connection Pool Sizing Modifications.
You can run the ttCacheConnPoolSet built-in procedure from a direct connection, a single-
threaded client/server connection or a multithreaded client/server connection.
Note:
See the ttCacheConnPoolSet in the Oracle TimesTen In-Memory Database
Reference.
For example, the following initiates the minimum and maximum number of pooled
connections to be between 10 and 32 connections and the increment is 1. The maximum idle
time by the client is set to 10 seconds. And all dynamic load operations will wait for an
available connection from the cache connection pool.
Command> call ttCacheConnPoolSet(10, 32, 1, 10, 0);
Set the minimum and maximum size of the cache connection pool to levels where
connections are available when needed. If no connections are available in the pool, dynamic
load operations stall until a connection from the pool is available (unless you set
7-5
Chapter 7
Dynamic Load Performance
ConnNoWait=1). If a connection to the Oracle database times out, you receive an error
denoting a loss of the connection, sometimes requiring a rollback on TimesTen.
You can query what the cache connection pool parameters are with the
ttCacheConnPoolGet built-in procedure.
The target child server process is identified by a value specified using the
ChildServer=n connection attribute, where n is a number ranging from 1 to the
number of running child server processes. When you specify the ChildServer
connection attribute, then the client process connects using the identified child server
process. If the attribute is not specified, then the client process connects using a
randomly selected child server process.
See ttCacheConnPoolApply and ttCacheConnPoolGet in the Oracle TimesTen In-
Memory Database Reference. See Example Demonstrating Management of the
Cache Connection Pool.
7-6
Chapter 7
Dynamic Load Performance
You can run the ttCacheConnPoolApply built-in procedure only from a multithreaded client/
server connection.
If the cache connection pool fails, you can recreate the pool by running the
ttCacheConnPoolApply built-in procedure from any child server process.
/* Query the values for the cache connection pool that are saved on the Oracle
database*/
Command> call ttCacheConnPoolGet('saved');
< 1, 10, 1, 10, 0, -1, -1, -1>
/* Query existing values for cache connection pool saved on the Oracle data base.
Since these are the saved values, this returns -1 for OpenCount, BusyCount
and LastOraErr. */
Command> call ttCacheConnPoolGet('saved');
< 1, 20, 1, 10, 0, -1, -1, -1 >
/* Query existing values for the current cache connection pool on this TimesTen
database */
Command> call ttCacheConnPoolGet('current');
< 1, 10, 1, 10, 0, 1, 0, 0 >
7-7
Chapter 7
Dynamic Load Performance
Note:
These calculations assume that all connections to the Oracle database are
client/server connections using a multithreaded server. The connections
referred to in the rest of this section are only those used for dynamic load
operations. There can be other connections from TimesTen to the Oracle
database that are not accounted for in these calculations.
7-8
Chapter 7
Improving AWT Throughput
The maximum number of connections (D) to the DSN is equal to the maximum number of
connections for each child server process (M) times the maximum number of TimesTen child
server processes (S).
D=M*S
Since there is no hard limit that we can configure for the number of TimesTen child server
processes, we substitute for S to get the following equation:
N=(D*P)/M
Assuming that all connections to the Oracle database are client/server connections, then the
maximum number of connections to the Oracle database arising from cache connection pools
is equal to the maximum number of connections to the DSN (set by the Connections
connection attribute) times the number of connections for each cache connection pool (set by
the MaxSize cache connection pool parameter), which is then divided by the maximum
number of connections for each child server process (set by the MaxConnsPerServer
connection attribute).
Note:
For TimesTen Scaleout, you may also want to limit the connections to the Oracle
database through limiting the number of cache agents. See Limiting Cache Agent
Connections to the Oracle Database in the Oracle TimesTen In-Memory Database
Scaleout User's Guide.
7-9
Chapter 7
Improving AWT Throughput
7-10
Chapter 7
Improving AWT Throughput
Note:
See Configuring Parallel Replication in the Oracle TimesTen In-Memory Database
Replication Guide. See ReplicationApplyOrdering, ReplicationParallelism, and
CacheAWTParallelism in the Oracle TimesTen In-Memory Database Reference.
These data store attributes are interrelated. Table 7-1 shows the result with the combination
of the various possible attribute values.
7-11
Chapter 7
Improving AWT Throughput
Foreign keys in Oracle Database tables that are to be cached must have indexes
created on the foreign keys. Consider these Oracle Database tables:
CREATE TABLE parent (c1 NUMBER PRIMARY KEY NOT NULL);
CREATE TABLE child (c1 NUMBER PRIMARY KEY NOT NULL,
c2 NUMBER REFERENCES parent(c1));
CREATE TABLE grchild (c1 NUMBER PRIMARY KEY NOT NULL,
c2 NUMBER REFERENCES parent(c1),
c3 NUMBER REFERENCES parent(c1));
The following sections describe restrictions, configuration and checks for parallel
propagation:
• Table Constraint Restrictions When Using Parallel Propagation for AWT Cache
Groups
• Manually Initiate Check for Missing Constraints for an AWT Cache Group
• Configuring Batch Size for Parallel Propagation for AWT Cache Groups
Table Constraint Restrictions When Using Parallel Propagation for AWT Cache
Groups
When you use parallel propagation for AWT cache groups, you must manually enforce
data consistency.
Any unique index, unique constraint, or foreign key constraint that exists on columns in
the Oracle Database tables that are to be cached should also be created on the AWT
cache tables within TimesTen. If you cannot create these constraints on the AWT
cache tables and you have configured for parallel propagation, then TimesTen
serializes any transactions with DML operations to any table with missing constraints.
For example, if a unique index created on a table in the Oracle database cannot be
created on the corresponding cached table in TimesTen, all transactions for this table
are serialized.
TimesTen automatically checks for missing constraints on the Oracle database that are
not cached on TimesTen when you issue any of the following SQL statements:
• When you create an AWT cache group with the CREATE ASYNCHRONOUS CACHE
GROUP statement
• When you create a unique index on an AWT cache table with the CREATE UNIQUE
INDEX statement
• When you drop a unique index on an AWT cache table with the DROP INDEX
statement
7-12
Chapter 7
Improving AWT Throughput
Note:
You can manually initiate a check for missing constraints with the ttCacheCheck
built-in procedure. For example, TimesTen does not automatically check for missing
constraints after a schema change on cached Oracle Database tables. After any
schema change on the Oracle database, you should perform an manual check for
missing constraints by running ttCacheCheck on the TimesTen database.
See Manually Initiate Check for Missing Constraints for an AWT Cache Group for
other conditions where you should manually check for missing constraints.
If the check notes missing constraints on the cached tables, TimesTen issues warnings about
each missing constraint.
For the following scenarios, the cached table is marked so that transactions that include DML
operations are serialized when propagated to the Oracle database.
• Transactions that apply DML operations to AWT cache tables that are missing unique
indexes or unique constraints.
• Missing foreign key constraints for tables within a single AWT cache group.
– If both the referencing table and the referenced table for the foreign key relationship
are in the same AWT cache group and the foreign key relationship is not defined,
both tables are marked for transaction serialization.
– If the referencing table is in an AWT cache group and the referenced table is not in
an AWT cache group, the table inside the cache group is not marked for transaction
serialization. Only a warning is issued to notify the user of the missing constraint.
– If the referenced table is in an AWT cache group and the referencing table is not in
an AWT cache group, the table inside the cache group is not marked for transaction
serialization. Only a warning is issued to notify the user of the missing constraint.
• Missing foreign key constraints between cache groups. When you have tables defined in
separate AWT cache groups that are missing a foreign key constraint, both tables are
marked for serialized transactions.
• If a missing foreign key constraint causes a chain of foreign key constraints to be broken
between two AWT cache groups, transactions for all tables within both AWT cache
groups are serialized.
Note:
An Oracle Database trigger may introduce an operational dependency of which
TimesTen may not be aware. In this case, you should either disable parallel
propagation for the AWT cache group or do not cache the table in an AWT cache
group on which the trigger is created.
The following is an example of missing constraints when creating an AWT cache group. This
example creates two tables in the sales schema in the Oracle database. There is a foreign
key relationship between active_customer and the ordertab tables. Because the examples
use these tables for parallel propagation, an index is created on the foreign key in the
ordertab table.
7-13
Chapter 7
Improving AWT Throughput
TimesTen automatically checks for missing constraints when each CREATE CACHE
GROUP is issued. In the following example, a single cache group is created that includes
the active_customer table. Only a warning is issued since the active_customer is the
referenced table and the referencing table, ordertab, is not in any AWT cache group.
The active_customer table is not marked for serialized transactions.
CREATE WRITETHROUGH CACHE GROUP update_cust
FROM sales.active_customer
(custid NUMBER(6) NOT NULL PRIMARY KEY,
name VARCHAR2(50),
addr VARCHAR2(100),
zip VARCHAR2(12));
Warning 5297: The following Oracle foreign key constraints on AWT cache table
SALES.ACTIVE_CUSTOMER contain cached columns that do not have corresponding
foreign key constraints on TimesTen: SALES.CUST_FK [Outside of CG].
The following example creates two AWT cache groups on TimesTen, one that includes
the active_customer table and the other includes the ordertab table. There is a
missing foreign key constraint between the cache groups. Thus, a warning is issued
for both tables, but only the ordertab table is marked for serial transactions since it is
the referencing table that should contain the foreign key.
CREATE WRITETHROUGH CACHE GROUP update_cust
FROM sales.active_customer
(custid NUMBER(6) NOT NULL PRIMARY KEY,
name VARCHAR2(50),
addr VARCHAR2(100),
zip VARCHAR2(12);
Warning 5297: The following Oracle foreign key constraints on AWT cache table
sales.update_customer contain cached columns that do not have corresponding
foreign key constraints on TimesTen: ordertab.cust_fk [Outside of CG].
7-14
Chapter 7
Improving AWT Throughput
Manually Initiate Check for Missing Constraints for an AWT Cache Group
The ttCacheCheck built-in procedure performs the same check for missing constraints for
cached tables on the Oracle database as performed automatically by TimesTen.
The ttCacheCheck provides appropriate messages about missing constraints and the tables
marked for serialized propagation. With the ttCacheCheck built-in procedure, you can check
for missing constraints for a given cache group or for all cache groups in TimesTen to ensure
that all cache groups are not missing constraints.
Note:
Since ttCacheCheck updates system tables to indicate if DML performed against a
table should or should not be serialized, you must commit or roll back after the
ttCacheCheck built-in completes.
You may need to manually call the ttCacheCheck built-in procedure to update the known
dependencies after any of the following scenarios:
• After dropping a series of AWT cache groups on TimesTen with the DROP CACHE GROUP
statement.
• After adding or dropping a unique index, unique constraint, or foreign key on an Oracle
Database table that is cached in an AWT cache group. If you do not call the
ttCacheCheck built-in procedure after adding a constraint, you may receive a run time
error on the AWT cache group. After dropping a constraint, TimesTen may serialize
transactions even if it is not necessary. Calling the ttCacheCheck built-in procedure
verifies whether serialization is necessary.
• You can use this built-in procedure to determine why some transactions are being
serialized.
Note:
The ttCacheCheck built-in procedure cannot be called while the replication agent is
running.
If a DDL statement is being performed on an AWT cache group when ttCacheCheck
is called, then ttCacheCheck waits for the statement to complete or until the timeout
period is reached.
If you have not defined the CacheAwtParallelism data store attribute to greater
than one or the specified cache group is not an AWT cache group, then the
ttCacheCheck built-in procedure returns an empty result set.
The following example shows the user manually running the ttCacheCheck built-in procedure
to determine if there are any missing constraints for an AWT cache group update_orders that
is owned by cacheadmin. A result set is returned that includes the error message. The
7-15
Chapter 7
Improving AWT Throughput
ordertab table in the update_orders cache group is marked for serially propagated
transactions.
Command> call ttCacheCheck(NULL, 'cacheadmin', 'update_orders');
Whenever the cache group schema changes in either the TimesTen or Oracle
databases, you can call ttCacheCheck against all AWT cache groups to verify all
constraints. The following example shows the user manually running the ttCacheCheck
built-in procedure to determine if there are any missing constraints for any AWT cache
group in the entire TimesTen database by providing a NULL value for all input
parameters. A result set is returned that includes any error messages.
Command> call ttCacheCheck(NULL, NULL, NULL);
Configuring Batch Size for Parallel Propagation for AWT Cache Groups
When using AWT cache groups, TimesTen batches together one or more transactions
that are to be applied in parallel to the back-end Oracle database. The
CacheParAwtBatchSize parameter configures a threshold value for the number of rows
included in a single batch. Once the maximum number of rows is reached, TimesTen
includes the rest of the rows in the transaction (TimesTen does not break up any
transactions), but does not add any more transactions to the batch.
For example, a user sets the CacheParAwtBatchSize to 200. For the next AWT
propagation, there are three transactions, each with 120 rows, that need to be
propagated and applied to the Oracle database. TimesTen includes the first two
transactions in the first batch for a total of 240 rows. The third transaction is included in
a second batch.
The default value for the CacheParAwtBatchSize parameter is 125 rows. The minimum
value is 1. See ttDBConfig in the Oracle TimesTen In-Memory Database Reference.
You can retrieve the current value of CacheParAwtBatchSize as follows:
call ttDBConfig('CacheParAwtBatchSize');
< CACHEPARAWTBATCHSIZE, 125 >
1 row found.
Set the CacheParAwtBatchSize parameter only when advised by Oracle Support, who
analyzes the workload and any dependencies in the workload to determine if a
7-16
Chapter 7
Improving Performance for Autorefresh Operations
Note:
You can also set this value with the ttDBConfig built-in procedure with the
CacheAwtMethod parameter. See ttDBConfig in the Oracle TimesTen In-Memory
Database Reference.
7-17
Chapter 7
Improving Performance for Autorefresh Operations
Note:
You cannot change the value of the DynamicLoadReduceContention
database system parameter if there are any dynamic read-only cache groups
or if the cache or replication agents are running. In order to change the value
of this parameter, you must unload and drop (and later recreate) any existing
dynamic read only cache groups, then stop the cache and replication agents.
7-18
Chapter 7
Improving Performance for Autorefresh Operations
Note:
See ttDBConfig in the Oracle TimesTen In-Memory Database Reference.
7-19
Chapter 7
Improving Performance for Autorefresh Operations
from the Oracle database (originating from a SELECT statement) and inserts the rows
into the cache group. Both the autorefresh and dynamic load operations require
access to the cache metadata, which could cause a lock contention.
At the end of an autorefresh operation, TimesTen updates the metadata to track the
autorefresh progress. If you have requested guaranteed durability by setting the
DurableCommits connection attribute to 1, then the autorefresh updates to the
metadata are always durably committed. If you have requested delayed durability by
setting the DurableCommits connection attribute to 0 (the default), then TimesTen must
ensure that the autorefresh updates to the metadata are durably committed before the
garbage collector can clean up the autorefresh tracking tables stored in the Oracle
database.
When a durable commit is initiated for the metadata, any previous non-durable
committed transactions in the transaction log buffer that have not been flushed to the
file system are also a part of the durable commit. On hosts with busy or slow file
systems, the durable commit could be slow enough to lock out dynamic load requests
for an undesirable amount of time.
If you notice that your application is timing out because of a lock contention between
autorefresh and dynamic load requests, you can set the CacheCommitDurable cache
configuration parameter to 0 with the ttCacheConfig built-in procedure. This reduces
the occurrence of lock contention between autorefresh and dynamic load requests in
the same application by:
• Running a non-durable commit of the autorefresh changes made to the metadata.
• Using a separate thread in the cache agent to durably commit the autorefresh
changes before the garbage collector cleans up the autorefresh tracking tables
stored in the Oracle database. This results in a slight performance cost as garbage
collection is delayed until after the durable commit completes.
The lock is removed after the non-durable commit of the autorefresh changes to the
metadata. After which, there is no longer a lock held on the metadata and any dynamic
load requests for the recently refreshed tables can continue processing without
waiting. However, if there is an error and database recovery starts, autorefresh may
need to reapply any committed transactions that did not flush to disk before a failure.
The following example sets CacheCommitDurable=0:
call ttCacheConfig('CacheCommitDurable',,,'0');
7-20
Chapter 7
Improving Performance for Autorefresh Operations
database system parameter by setting the value to 1 with the ttDbConfig built-in
procedure. See Reducing Contention for Dynamic Read-Only Cache Groups With
Incremental Autorefresh.
• If you notice that commit operations for autorefresh are taking an unusually long time,
then look for a TT47087 informational message in the support log. Locate the
tt1stXactCommitTime and tt2ndXactCommitTime entries within this message. If the time
indicated for either of both of these entries unusually high or is a major portion of the time
indicated in the Duration entry, this may indicate that the durable commit of transaction
logs is slow. In this case, you have the option to set the CacheCommitDurable cache
configuration parameter to 0 with the ttCacheConfig built-in procedure. For more details
on the CacheCommitDurable cache configuration parameter, see Reducing Lock
Contention for Read-Only Cache Groups With Autorefresh and Dynamic Load.
Enable both options if there is a small autorefresh interval in conjunction with a high number
of dynamic load requests.
7-21
Chapter 7
Improving Performance for Autorefresh Operations
Note:
For more details, see ttDBConfig in the Oracle TimesTen In-Memory
Database Reference.
To determine if you should increment the size for the cache agent reclaim buffer,
evaluate the CommitBufMaxReached and CommitBufNumOverflows statistics provided by
the ttCacheAutorefIntervalStatsGet built-in procedure. See Retrieving Statistics on
Autorefresh Transactions.
Note:
The autorefresh transaction limit can only be set for static read-only cache
groups.
7-22
Chapter 7
Improving Performance for Autorefresh Operations
Note:
If you are using an active standby pair, you must call the
ttCacheAutorefreshXactLimit built-in procedure for the same values on both the
active and standby masters.
Using ttCacheAutorefreshXactLimit
Note:
See ttCacheAutorefreshXactLimit in the Oracle TimesTen In-Memory Database
Reference.
For the month end processing, there can be a large number updates in a single transaction
for the Oracle tables that are cached in cache groups with autorefresh. In order to ensure that
the large transaction does not fill up permanent memory, you can enable autorefresh to
commit after every 256 (or any other user specified number) operations with the
ttCacheAutorefreshXactLimit built-in procedure.
Turn on an autorefresh transaction limit for incremental autorefresh read-only cache groups
before a large transaction with the ttCacheAutorefreshXactLimit built-in procedure where
the value is set to ON or to a specific number of operations. Then, when autorefresh finishes
updating the cached tables in TimesTen, turn off the autorefresh transaction limit for
incremental autorefresh read-only cache groups with the ttCacheAutorefreshXactLimit
built-in procedure.
The following example sets up the transaction limit to commit after every 256 operations for
all incremental autorefresh read-only cache groups that are defined with an interval value of
10 seconds.
call ttCacheAutorefreshXactLimit('10000', 'ON');
After the month end process has completed and the incremental autorefresh read-only cache
groups are refreshed, disable the transaction limit for incremental autorefresh read-only
cache groups that are defined with the interval value of 10 seconds.
call ttCacheAutorefreshXactLimit('10000', 'OFF');
To enable the transaction limit for incremental autorefresh read-only cache groups to commit
after every 1024 operations, provide 1024 as the value as follows:
call ttCacheAutorefreshXactLimit('10000', '1024');
7-23
Chapter 7
Improving Performance for Autorefresh Operations
2. Create the incremental autorefresh read-only cache groups with interval of two
seconds. This example creates two static (non-dynamic) read-only cache groups,
where each contains a single table.
CREATE READONLY CACHE GROUP cgDepts AUTOREFRESH MODE INCREMENTAL
INTERVAL 2 SECONDS
FROM departments
( department_id NUMBER(4) PRIMARY KEY
, department_name VARCHAR2(30) NOT NULL
, manager_id NUMBER(6)
, location_id NUMBER(4)
);
3. Run a LOAD CACHE GROUP statement for both cache groups with autorefresh.
LOAD CACHE GROUP cgDepts COMMIT EVERY 256 ROWS;
27 cache instances affected.
7-24
Chapter 7
Improving Performance for Autorefresh Operations
You can have inconsistency within the table during an autorefresh as shown with the
employees table.
1. On TimesTen, select the minimum and maximum salary of all employees.
SELECT MIN(salary), MAX(salary) FROM employees;
< 2100, 24000 >
1 row found.
3. On TimesTen, when you run the SELECT again (while the autorefresh transactions are
commmitted after every 3 records), it shows that while the maximum salary has updated,
the minimum salary is still the old value.
SELECT MIN(salary), MAX(salary) FROM employees;
< 2100, 124000 >
1 row found.
5. The large transaction is complete, so disable the transaction limit for cache groups with a
2 second interval autorefresh.
call ttCacheAutorefreshXactLimit('2000', 'OFF');
You can have transactional inconsistency between cache groups if you run a SQL statement
while the autorefresh process is progressing. The following SELECT statement example runs
against the employees and department table in the cgDepts autorefresh cache group. With
this example, since the foreign key is not enforced on TimesTen and the autorefresh process
applies several transactions, the employee table updates may be inserted before the
department updates.
In addition, all of the updates for both tables in the cache group are not applied until the
autorefresh cycle has completed. In the following example, the SELECT statement is
performed before the autorefresh process is complete. Thus, the results do not show all of
the expected data, such as the department name and several employees (some of the
lawyers in the legal department 1000) are missing.
SELECT e.department_id, d.DEPARTMENT_NAME, e.FIRST_NAME, e.LAST_NAME
FROM employees e, departments d
WHERE e.DEPARTMENT_ID = d.DEPARTMENT_ID (+)
AND e.department_id >= 1000 ORDER BY 1,2,3,4;
< 1000, Legal, Alec, Dunkle >
< 1000, Legal, Barry, Strong >
< 1000, Legal, Leigh, Harrison >
3 rows found.
7-25
Chapter 7
Improving Performance for Autorefresh Operations
For cache groups with autorefresh that have more than one table, you can also
experience transactional inconsistency if you run SQL statements while the
autorefresh process is in progress.
1. Initiate the transaction limit for incremental cache groups with autorefresh of 2
seconds with the ttCacheAutorefreshXactLimit built-in procedure and create a
single autorefresh cache group with two tables: the employees and departments
tables.
CALL ttCacheAutorefreshXactLimit('2000', '3');
< 2000, 3 >
1 row found.
3. Run a SELECT statement on TimesTen that uploads all of the legal department
data.
SELECT e.department_id, d.department_name, count(*)
FROM employees e, departments d
WHERE e.department_id = d.department_id (+)
GROUP BY e.department_id, d.department_name
ORDER BY 1 desc;
< 110, Accounting, 2 >
< 100, Finance, 6 >
< 90, Executive, 3 >
7-26
Chapter 7
Improving Performance for Autorefresh Operations
4. On Oracle, insert a new legal department, numbered 1000, with 6 new lawyers in both
the employee and department tables.
5. When performing a SELECT statement on TimesTen during the autorefresh process, only
data on two of the lawyers in department 1000 have been uploaded into TimesTen.
SELECT e.department_id, d.department_name, count(*)
FROM employees e, departments d
WHERE e.department_id = d.department_id (+)
GROUP BY e.department_id, d.department_name
ORDER BY 1 desc;
< 1000, Legal, 2 >
< 110, Accounting, 2 >
< 100, Finance, 6 >
< 90, Executive, 3 >
< 80, Sales, 34 >
< 70, Public Relations, 1 >
< 60, IT, 5 >
< 50, Shipping, 45 >
< 40, Human Resources, 1 >
< 30, Purchasing, 6 >
< 20, Marketing, 2 >
< 10, Administration, 1 >
12 rows found.
6. However, after the autorefresh process completes, all 6 employees (lawyers) in the legal
department have been uploaded to TimesTen. Now, it is transactionally consistent.
SELECT e.department_id, d.department_name, COUNT(*)
FROM employees e, departments d
WHERE e.department_id = d.department_id (+)
GROUP BY e.department_id, d.department_name
ORDER BY 1 desc;
< 1000, Legal, 6 >
< 110, Accounting, 2 >
< 100, Finance, 6 >
< 90, Executive, 3 >
< 80, Sales, 34 >
< 70, Public Relations, 1 >
< 60, IT, 5 >
< 50, Shipping, 45 >
< 40, Human Resources, 1 >
< 30, Purchasing, 6 >
< 20, Marketing, 2 >
< 10, Administration, 1 >
12 rows found.
7. The large transaction is complete, so disable the transaction limit for cache groups with a
2 second autorefresh interval.
call ttCacheAutorefreshXactLimit('2000', 'OFF');
7-27
Chapter 7
Improving Performance for Autorefresh Operations
Note:
The select limit can only be set for static read-only cache groups. To protect
instance consistency, we recommend that you set the select limit only on
cache groups with only a single table.
Autorefresh continues to apply changes to the cached table incrementally until all the
rows in the autorefresh change log table have been applied. When there are no rows
left to apply, the autorefresh thread sleeps for the rest of the interval period.
Note:
See ttCacheAutorefreshSelectLimit in the Oracle TimesTen In-Memory
Database Reference.
7-28
Chapter 7
Improving Performance for Autorefresh Operations
The following example set a select limit to 2000 rows for cache groups with incremental
autorefresh where the interval value is 7 seconds.
Command> call ttCacheAutorefreshSelectLimit('7000', '2000');
< 7000, 2000 >
1 row found.
You can disable any select limit for cache groups with incremental autorefresh where the
interval value is 10 seconds by setting the value to OFF.
Command> call ttCacheAutorefreshSelectLimit('10000', 'OFF');
< 10000, OFF >
1 row found.
The following sections describe details when configuring a select limit for static read-only
cache groups with incremental autorefresh.
• See How to Determine Which Intervals Have a Particular Select Limit to determine which
intervals have a select limit.
• See Retrieving Statistics on Autorefresh Transactions to retrieve statistics for incremental
autorefresh transactions for this autorefresh interval. This determines how a select limit
for a particular autorefresh interval is performing.
This returns all attributes for the cgowner.cgname cache group including the interval.
To determine which intervals have a select limit, you can run the following query on the
Oracle database where <cacheAdminUser> is the cache administrator, <hostName> is the host
name of the machine where the TimesTen database is located, <databaseFileName> is the
database path taken from the DataStore attribute, and substitute the version number (such
as 07) for the xx.
SELECT * FROM <cacheAdminUser>.tt_xx_arinterval_params
WHERE param='AutorefreshSelectEveryN'
AND host='<hostName>'
AND database like '%<databaseFileName>%'
ORDER BY arinterval;
For example, if the cache administrator user name is pat, the host name is myhost, the
database file name is myTtDb, and 07 is substituted for xx that is the TimesTen minor release
number then:
SELECT * FROM pat.tt_07_arinterval_params
WHERE param='AutorefreshSelectEveryN'
AND host='myhost'
AND database like '%myTtDb%'
ORDER BY arinterval;
7-29
Chapter 7
Retrieving Statistics on Autorefresh Transactions
Note:
See ttCacheAutorefIntervalStatsGet in the Oracle TimesTen In-Memory
Database Reference.
This built-in procedure is useful if you have set an transaction limit or a select
limit for incremental, autorefresh read-only cache groups. See Running
Large Transactions With Incremental Autorefresh Read-Only Cache Groups
and Configuring a Select Limit for Incremental Autorefresh for Read-Only
Cache Groups.
< 2000, 1, 21, 2013-04-30 06:05:38.000000, 100, 3761, 3761, 822, 1048576,
1280, 0, 58825, 63825, 13590, 0, 0, 0, 0, 0 >
< 2000, 1, 20, 2013-04-30 06:05:37.000000, 100, 85, 85, 18, 1048576, 1280,
0, 55064, 60064, 12768, 0, 0, 0, 0, 0 >
< 2000, 1, 19, 2013-04-30 06:05:32.000000, 100, 3043, 3043, 666, 1048576,
1280, 0, 54979, 59979, 12750, 0, 0, 0, 0, 0 >
< 2000, 1, 18, 2013-04-30 06:05:30.000000, 100, 344, 344, 74, 1048576,
1280, 0, 51936, 56936, 12084, 0, 0, 0, 0, 0 >
< 2000, 1, 17, 2013-04-30 06:05:28.000000, 100, 1826, 1826, 382, 1048576,
1280, 0, 51592, 56592, 12010, 0, 0, 0, 0, 0 >
< 2000, 1, 16, 2013-04-30 06:05:26.000000, 100, 55, 55, 12, 1048576,
1280, 0, 49766, 54766, 11628, 0, 0, 0, 0, 0 >
< 2000, 1, 15, 2013-04-30 06:05:22.000000, 100, 2901, 2901, 634, 1048576,
1280, 0, 49711, 54711, 11616, 0, 0, 0, 0, 0 >
< 2000, 1, 14, 2013-04-30 06:05:21.000000, 100, 55, 55, 12, 1048576,
1280, 0, 46810, 51810, 10982, 0, 0, 0, 0, 0 >
< 2000, 1, 13, 2013-04-30 06:05:10.000000, 100, 5844, 5844, 1263, 1048576,
1280, 0, 46755, 51755, 10970, 0, 0, 0, 0, 0 >
< 2000, 1, 12, 2013-04-30 06:05:08.000000, 100, 607, 607, 132, 1048576,
1280, 0, 40911, 45911, 9707, 0, 0, 0, 0, 0 >
10 rows found.
7-30
Chapter 7
Caching the Same Oracle Table on Two or More TimesTen Databases
7-31
8
Cleaning Up the Caching Environment
There are specific tasks that need to be performed in the TimesTen and Oracle databases to
drop cache groups. You should shut down all components when using AWT cache groups.
• Stopping the Replication Agent
• Dropping a Cache Group
• Stopping the Cache Agent
• Destroying the TimesTen Databases
• Dropping Oracle Database Users and Objects
• Scheduling a Shutdown of Active Standby Pair With AWT Cache Groups
This must be done on each TimesTen database of the active standby pair including any read-
only subscriber databases, and any standalone TimesTen databases that contain AWT cache
groups.
From the cache1, cache2, cacheactive, cachestandby and rosubscriber databases, call the
ttRepStop built-in procedure as the TimesTen cache administration user to stop the
replication agent on the database:
Command> CALL ttRepStop;
Oracle Database objects used to manage the caching of Oracle Database data are
automatically dropped when you use the DROP CACHE GROUP statement to drop a cache group,
or an ALTER CACHE GROUP statement to set the autorefresh state to OFF for cache groups with
autorefresh.
If you issue a DROP CACHE GROUP statement on a cache group that has an autorefresh
operation in progress:
• The autorefresh operation stops if the LockWait connection attribute setting is greater
than 0. The DROP CACHE GROUP statement preempts the autorefresh operation.
• The autorefresh operation continues if the LockWait connection attribute setting is 0. The
DROP CACHE GROUP statement is blocked until the autorefresh operation completes or the
statement fails with a lock timeout error.
If you have created an AWT cache group, a replication scheme is created to enable
committed changes on its cache tables to be asynchronously propagated to the cached
8-1
Chapter 8
Stopping the Cache Agent
Oracle tables. This replication scheme is automatically dropped when you drop the
AWT cache group. Thus, perform the following before dropping an AWT cache group:
1. Use the ttRepSubscriberWait built-in procedure to make sure that all committed
changes on its cache tables have been propagated to the cached Oracle
Database tables before dropping the AWT cache group.
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> CALL
ttRepSubscriberWait('_AWTREPSCHEME','TTREP','_ORACLE','sys1',-1);
2. The cache tables in an AWT cache group are replicated in an active standby pair.
If the cache tables are the only tables that are being replicated, drop the active
standby pair using a DROP ACTIVE STANDBY PAIR statement before dropping the
AWT cache groups.
Run the following statement as the TimesTen cache administration user on the
cacheactive, cachestandby and rosubscriber databases to drop the active
standby pair replication scheme:
Command> DROP ACTIVE STANDBY PAIR;
Command> exit
2. Use a DROP CACHE GROUP statement to drop the cache groups from the standalone
TimesTen databases and, if using an AWT cache group, the active and standby
databases.
Run the following statement as the TimesTen cache administration user on the
cache1, cache2, cacheactive and cachestandby databases to drop the
subscriber_accounts cache group. The following example shows the SQL
statement issued from the cache1 database:
% ttIsql "DSN=cache1;UID=cacheadmin;PWD=timesten;OraclePWD=orapwd"
Command> DROP CACHE GROUP subscriber_accounts;
The DROP CACHE GROUP statement updates the metadata on the Oracle database.
The objects are dropped if no other TimseTen databases are caching the same
tables.
8-2
Chapter 8
Destroying the TimesTen Databases
• In TimesTen Classic, call the ttCacheStop built-in procedure to stop the cache agent.
This must be done on all standalone TimesTen databases and, if used, the active and
standby databases of the active standby pair.
From the cache1, cache2, cacheactive and cachestandby databases, issue the following
built-in procedure call to stop the cache agent on the database:
Command> CALL ttCacheStop;
Command> exit
Note:
In TimesTen Classic, if the RAM policy designates that the database stays
in memory, then this may prevent you from destroying the database. For
example, if the RAM policy is set to always, then you must change the RAM
policy to manual and run the ttAdmin -ramunload command to unload the
database before destroying the database. See Specifying a RAM Policy
section in the Oracle TimesTen In-Memory Database Operations Guide.
The following example shows the ttDestroy utility connecting to and then destroying
the cache1 database:
% ttDestroy cache1
4. If you used the -force option on the destroy operation, run the following script to cleanup
the metadata and Oracle database objects.
• For TimesTen Scaleout, run the scaleoutCacheCleanup.sql script.
• For TimesTen Classic, run the cacheCleanup.sql script.
See Installed SQL*Plus Scripts.
8-3
Chapter 8
Dropping Oracle Database Users and Objects
Also, you can run TimesTen SQL*Plus scripts to drop the Oracle Database objects
used to implement autorefresh operations. See Managing a Cache Environment With
Oracle Database Objects.
8-4
Chapter 8
Scheduling a Shutdown of Active Standby Pair With AWT Cache Groups
pending transactions are applied to the Oracle database. Thus, shutting down TimesTen
before the Oracle database provides the most efficient method for your scheduled shutdown
and startup. In addition, shutting down the applications before TimesTen stops any additional
requests from being sent to an unavailable TimesTen database.
8-5
9
Using Cache in an Oracle RAC Environment
The following sections describe how to use cache in an Oracle Real Application Clusters
(Oracle RAC) environment:
• How Cache Works in an Oracle RAC Environment
• Restrictions on Using Cache in an Oracle RAC Environment
• Setting Up Cache in an Oracle RAC Environment
Note:
You can configure how long TAF retries when establishing a connection with the
AgentFailoverTimeout parameter. For details, see Setting Up Cache in an Oracle
RAC Environment.
9-1
Chapter 9
How Cache Works in an Oracle RAC Environment
OCI applications can use one of the following types of Oracle Net failover functionality:
• None: No failover functionality is used. This can also be specified to prevent
failover from happening. This is the default failover functionality.
• Session: If an application's connection is lost, a new connection is automatically
created for the application. This type of failover does not attempt to recover
selects.
• Select: This type of failover enables applications that began fetching rows from a
cursor before failover to continue fetching rows after failover.
The behavior of cache operations depend on the actions of TAF and how TAF is
configured. By default, TAF and FAN callbacks are installed if you are using cache in
an Oracle RAC environment. If you do not want TAF and FAN capabilities, set the
RACCallback connection attribute to 0.
Table 9-1 shows the behaviors of cache operations in an Oracle RAC environment
with different TAF failover types.
9-2
Chapter 9
How Cache Works in an Oracle RAC Environment
9-3
Chapter 9
Restrictions on Using Cache in an Oracle RAC Environment
9-4
Chapter 9
Setting Up Cache in an Oracle RAC Environment
reconnect with the Oracle database every minute; the replication agent restarts any
threads that cannot connect to the Oracle database.
If you are using TimesTen Scaleout, you must run the ttCacheConfig built-in procedure
on every data instance in the database. See ttCacheConfig in the Oracle TimesTen In-
Memory Database Reference.
2. Make sure that the TimesTen daemon, the cache agent, and the following Oracle
Database components are started:
• Oracle Database instances
• Oracle Database listeners
• Oracle Database service that is used for cache operations
3. Verify that the TimesTen RACCallback connection attribute is set to 1 (default). See
RACCallback in the Oracle TimesTen In-Memory Database Reference.
4. Use the DBMS_SERVICE.MODIFY_SERVICE function or Oracle Enterprise Manager to enable
publishing of FAN events. This changes the value in the AQ_HA_NOTIFICATIONS column of
the Oracle Database ALL_SERVICES view to YES.
See Oracle Database PL/SQL Packages and Types Reference for more information
about the DBMS_SERVICE Oracle Database PL/SQL package.
5. Enable TAF on the Oracle Database service used for cache operations on TimesTen with
one of the following methods:
• Create a service for TimesTen in the Oracle Database tnsnames.ora file with the
following settings:
– LOAD_BALANCE=ON (optional)
– FAILOVER_MODE=(TYPE=SELECT) or FAILOVER_MODE=(TYPE=SESSION)
• Use the DBMS_SERVICE.MODIFY_SERVICE function to set the TAF failover type.
See Oracle Database Net Services Administrator's Guide for more information about
enabling TAF.
6. If you have a TimesTen application that uses the direct driver, link it with a thread library
so that it receives FAN notifications. FAN spawns a thread to monitor for failures.
9-5
10
Using Cache With Data Guard
You need to configure cache when you want cache to work with either synchronous or
asynchronous Data Guard. Data Guard support is only included within TimesTen Classic.
• Components of MAA for Cache
• Cache in TimesTen Works With Asynchronous Active Data Guard
• Cache in TimesTen Works With Synchronous Data Guard
10-1
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
The Active Data Guard configuration includes a primary Oracle database that
communicates over an asynchronous transport to a single physical standby Oracle
database. As shown in Figure 10-1, the primary Oracle database is located on the
primary site, while the standby Oracle database is located on a disaster recovery site.
ADG enabled
Active Standby read-only
master replicated master replicated subscriber
updates updates
autorefresh
updates primary standby
Oracle Active Data Guard Oracle
Database Database
On TimesTen, the read-only cache groups on the primary site are autorefreshed from
the primary Oracle database; however, the only transactions that are autorefreshed
are those whose changes have been successfully replicated to the standby Oracle
database. Once refreshed to the active master, all changes are then propagated to the
TimesTen standby master and a read-only subscriber using standard TimesTen
replication processes.
For the best failover and recovery action, you should locate the read-only subscriber
on the same disaster recovery site as the standby Oracle database. Create this read-
only subscriber with the ttRepAdmin -duplicate -activeDataGuard utility option,
which replicates the read-only cache groups directly to the subscriber as it would to a
standby master database. That is, instead of the cache groups being converted to
tables when replicated to a subscriber, the cache groups themselves are replicated to
the read-only subscriber. This is to provide a recovery and failover option if the primary
site fails. See Recovery After Failure When Using Asynchronous Active Data Guard.
The following sections provide more details on the environment for asynchronous
Active Data Guard when using replicated read-only cache groups:
• Configuring the Primary and Standby Oracle Databases
• Configuring the Active Standby Pair With Read-Only Cache Groups
• Recovery After Failure When Using Asynchronous Active Data Guard
10-2
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
2. On the primary Oracle database, add the standbyrole database service. This service
starts only if this Oracle database switches to the standby role and then provides real-
time reporting on the standby Oracle database.
srvctl add service -d Austin -s standbyrole -r ssa1,ssa2,ssa3,
ssa4 -l PHYSICAL_STANDBY -q TRUE -e SESSION -m BASIC -w 10 -z 150
3. On the standby Oracle database, add the primaryrole database service. This service
starts only if this Oracle database switches to the primary role.
10-3
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
4. On the standby Oracle database, add the standbyrole database service. While
this Oracle database acts as the standby, this service is started and then provides
real-time reporting on the standby Oracle database.
srvctl add service -d Houston -s standbyrole -r ssb1,ssb2,ssb3,
ssb4 -l PHYSICAL_STANDBY -q TRUE -e SESSION -m BASIC -w 10 -z 150
5. Run the following SQL statement on the primary Oracle database so that the
service definitions are transmitted and applied to the physical standby Oracle
database.
EXECUTE DBMS_SERVICE.CREATE_SERVICE('standbyrole', 'standbyrole', NULL,
NULL, TRUE, 'BASIC', 'SESSION', 150, 10, NULL);
(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=myhost2)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=primaryrole))))
standbyinstance=
(DESCRIPTION_LIST=
(LOAD_BALANCE=off)
(FAILOVER=on)
(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=myhost1)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=standbyrole)))
(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=myhost2)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=standbyrole))))
10-4
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
exec DBMS_SERVICE.CREATE_SERVICE(
service_name => 'primaryrole',
network_name => 'primaryrole',
aq_ha_notifications => true, failover_method => 'BASIC',
failover_type => 'SELECT', failover_retries => 180, failover_delay => 1 );
exec DBMS_SERVICE.CREATE_SERVICE(
service_name => 'standbyrole',
network_name => 'standbyrole',
aq_ha_notifications => true, failover_method => 'BASIC',
failover_type => 'SELECT', failover_retries => 180, failover_delay => 1 );
2. Create the primaryrole and standbyrole triggers in the primary Oracle database for
when the database starts.
CREATE OR REPLACE TRIGGER manage_OCIService
after startup on database
DECLARE
role VARCHAR(30);
BEGIN
SELECT DATABASE_ROLE INTO role FROM V$DATABASE;
IF role = 'PRIMARY' THEN
BEGIN
DBMS_SERVICE.START_SERVICE('primaryrole');
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
DBMS_SERVICE.STOP_SERVICE('standbyrole');
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
ELSE
BEGIN
DBMS_SERVICE.STOP_SERVICE('primaryrole');
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
DBMS_SERVICE.START_SERVICE('standbyrole');
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END IF;
END;
3. Create the following trigger on the primary Oracle database to run when the database
changes roles:
CREATE OR REPLACE TRIGGER manage_OCIService2
AFTER DB_ROLE_CHANGE ON DATABASE
DECLARE
role VARCHAR(30);
BEGIN
SELECT DATABASE_ROLE INTO role FROM V$DATABASE;
IF role = 'PRIMARY' THEN
BEGIN
DBMS_SERVICE.START_SERVICE('primaryrole');
10-5
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
DBMS_SERVICE.STOP_SERVICE('standbyrole');
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
ELSE
BEGIN
DBMS_SERVICE.STOP_SERVICE('primaryrole');
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
BEGIN
DBMS_SERVICE.START_SERVICE('standbyrole');
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END IF;
END;
(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=myhost2)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=primaryrole))))
standbyinstance=
(DESCRIPTION_LIST=
(LOAD_BALANCE=off)
(FAILOVER=on)
(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=myhost1)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=standbyrole)))
(DESCRIPTION=(ADDRESS_LIST=(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=myhost2)(PORT=1521)))
(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=standbyrole))))
5. Restart both of the Oracle databases to enable the trigger to start and stop the
correct database services. Alternatively, if you do not want to restart both Oracle
databases, you can start and stop the appropriate database services on each
Oracle database as follows:
On the primary Oracle database:
10-6
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
exec DBMS_SERVICE.START_SERVICE('primaryrole');
exec DBMS_SERVICE.STOP_SERVICE('standbyrole');
Note:
Alternatively, you can use the ttRepDuplicateEx C function setting the
TT_REPDUP_ADG flag in ttRepDuplicateExArg.flags.
The following example creates a read-only subscriber on the disaster recovery site
duplicating from the standby master providing the -activeDataGuard option, the cache
administration user name and passwords.
ttRepAdmin -duplicate -from master2 -host node1
-uid cacheadmin -pwd timesten -cacheuid cacheadmin -cachepwd orapwd
-activeDataGuard adgsubscriber
3. Create the cache environment on the primary Oracle database. You do not need to
perform any of these steps on the standby Oracle database.
4. On the primary Oracle database, grant the Oracle cache administration user the EXECUTE
privilege for the SYS.DBMS_FLASHBACK package. This privilege is granted as part of the
initCacheAdminSchema.sql and grantCacheAdminPrivileges.sql scripts.
10-7
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
5. Configure the same connection attributes that you would for a TimesTen database
that caches data from an Oracle database. In addition, since we are also
monitoring transactions from the standby Oracle database, configure the
StandbyNetServiceName connection attribute with the net service name of the
standby Oracle database instance.
On Microsoft Windows systems, the net service name of the Oracle database
instance is specified in the Oracle Net Service Name field of the TimesTen Cache
tab within the TimesTen ODBC Setup dialog box. The standby Oracle database
instance is specified in the Standby Oracle Net Service Name field on the same
page.
Configure the StandbyNetServiceName ODBC.INI attribute on the active master to
configure the net service name of the physical standby Oracle database:
[cachedb]
DataStore=/myDb/cachedb
PermSize=256
TempSize=256
DatabaseCharacterSet=WE8DEC
OracleNetServiceName=primaryinstance
StandbyNetServiceName=standbyinstance
Note:
You can notify the cache agent of whether the standby Oracle database is
active or has failed by calling the ttCacheADGStandbyStateSet built-in
procedure with either the ON or the FAILED arguments.
• If a timeout is set, then the cache agent waits for the amount of time specified with
the ttCacheADGStandbyTimeoutSet built-in procedure. If the standby Oracle
database has not recovered after this period, then the cache agent sets the state
of the standby Oracle database by calling the ttCacheADGStandbyStateSet built-in
procedure with the FAILED argument and then facilitates autorefresh using only the
primary Oracle database.
• If no timeout has been set with the ttCacheADGStandbyTimeoutSet built-in
procedure (default value is 0), then the cache agent continues to wait on the
10-8
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
standby Oracle database, unless you inform the cache agent that the standby Oracle
database is not recovering by calling the ttCacheADGStandbyStateSet built-in procedure
with the FAILED argument.
Once the state of the standby Oracle database is set to FAILED, the cache agent resumes
autorefresh with only the primary Oracle database until you reset the state of the standby
Oracle database by calling the ttCacheADGStandbyStateSet built-in procedure with the ON
argument. Even if the standby Oracle database eventually does recover, the cache agent
does not recognize that the standby Oracle database is active until you reset its state to ON.
Once the state of the standby Oracle database is set to ON, the cache agent pauses to wait
for the standby Oracle database to catch up to the primary Oracle database. After which, the
cache agent resumes autorefresh from the primary Oracle database for those transactions
that have successfully replicated to the standby Oracle database.
You can restore the original Active Data Guard configuration by dropping the active standby
pair and then loading the cache groups.
See ttCacheADGStandbyTimeoutSet and ttCacheADGStandbyStateSet in the Oracle
TimesTen In-Memory Database Reference.
ADG enabled
Active Standby read-only
master replicated master replicated subscriber
updates updates
autorefresh
primary Oracle updates standby Oracle
database database
Disaster
Primary Site Recovery
Site application
updates
10-9
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
Disaster replicated
Primary Site Recovery updates
Fails! Site
FAILED
primary primary
Oracle Oracle
Database Database
application
updates
The following is the process to recover a failed primary site and rebuild your
environment to the original state:
1. Create a new active standby pair on the disaster recovery site.
10-10
Chapter 10
Cache in TimesTen Works With Asynchronous Active Data Guard
2. Alter the existing read-only cache groups on the disaster recovery site to set the
autorefresh state to off to stop any future updates from the primary Oracle database.
3. Create the ADG enabled read-only subscriber on the recovered primary site.
4. Drop the active standby pair on the ADG enabled read-only subscriber on the primary
site, if it still exists after recovering the primary site.
5. Switch over the Oracle databases in the Active Data Guard. Currently, the applications
are updating the primary Oracle database on the disaster recovery site. However, once
you recover the Oracle database on the primary site, we want it to take over again as the
primary and to make the Oracle database on the disaster recovery site as the secondary.
The TimesTen database starts to receive updates from the Oracle database on the
primary site.
ADG enabled
read-only Active
Standby
subscriber
master master
10-11
Chapter 10
Cache in TimesTen Works With Synchronous Data Guard
ADG enabled
Active Standby Read-only
master master subscriber
7. Create a new
ADG enabled read-only
subscriber on the
disaster recovery site.
6. Create a new active
standby pair on the primary Oracle standby Oracle
primary site. database Active Data Guard database
10-12
Chapter 10
Cache in TimesTen Works With Synchronous Data Guard
1. The Data Guard configuration must be managed by the Data Guard Broker so that the
TimesTen daemon processes and application clients respond faster to failover and
switchover events.
2. If you are configuring an Oracle RAC database, use the Oracle Enterprise Manager
Cluster Managed Database Services Page to create Oracle database services that
TimesTen and its client applications use to connect to the Oracle primary database. See
Workload Management With Dynamic Database Services in Oracle Real Application
Clusters Administration and Deployment Guide.
3. If you created the Oracle database service in step 2, use the MODIFY_SERVICE function of
the DBMS_SERVICE PL/SQL package to modify the service to enable high availability
notification to be sent through Advanced Queuing (AQ) by setting the
aq_ha_notifications attribute to TRUE. To configure server side TAF settings, set the
failover attributes, as shown in the following example:
BEGIN
DBMS_SERVICE.MODIFY_SERVICE
(service_name => 'DBSERV',
goal => DBMS_SERVICE.GOAL_NONE,
dtp => false,
aq_ha_notifications => true,
failover_method => 'BASIC',
failover_type => 'SELECT',
failover_retries => 180,
failover_delay => 1);
END;
4. If you did not create the database service in step 2, use the CREATE_SERVICE function of
the DBMS_SERVICE PL/SQL package to create the database service, enable high
availability notification, and configure server side TAF settings:
BEGIN
DBMS_SERVICE.CREATE_SERVICE
(service_name => 'DBSERV',
network_name => 'DBSERV',
goal => DBMS_SERVICE.GOAL_NONE,
dtp => false,
aq_ha_notifications => true,
failover_method => 'BASIC',
failover_type => 'SELECT',
failover_retries => 180,
failover_delay => 1);
END;
5. Create two triggers to relocate the database service to a Data Guard standby database
(Oracle RAC or non-Oracle RAC) after it has switched to the primary role. The first trigger
fires on the system start event and starts up the DBSERV service:
CREATE OR REPLACE TRIGGER manage_service
AFTER STARTUP ON DATABASE
DECLARE
role VARCHAR(30);
BEGIN
SELECT database_role INTO role FROM v$database;
IF role = 'PRIMARY' THEN
dbms_service.start_service('DBSERV');
END IF;
END;
10-13
Chapter 10
Cache in TimesTen Works With Synchronous Data Guard
The second trigger fires when the standby database remains open during a
failover and switchover upon a database role change. It relocates the DBSERV
service from the old primary to the new primary database and disconnects any
connections to that service on the old primary database so that TimesTen and its
client applications can reconnect to the new primary database:
CREATE OR REPLACE TRIGGER relocate_service
AFTER DB_ROLE_CHANGE ON DATABASE
DECLARE
role VARCHAR(30);
BEGIN
SELECT database_role INTO role FROM v$database;
IF role = 'PRIMARY' THEN
dbms_service.start_service('DBSERV');
ELSE
dbms_service.stop_service('DBSERV');
dbms_lock.sleep(2);
FOR x IN (SELECT s.sid, s.serial#
FROM v$session s, v$process p
WHERE s.service_name='DBSERV' AND s.paddr=p.addr)
LOOP
BEGIN
EXECUTE IMMEDIATE
'ALTER SYSTEM DISCONNECT SESSION
''' || x.sid || ','|| x.serial# || ''' IMMEDIATE';
EXCEPTION WHEN OTHERS THEN
BEGIN
DBMS_OUTPUT.PUT_LINE(DBMS_UTILITY.FORMAT_ERROR_STACK);
END;
END;
END LOOP;
END IF;
END;
10-14
Chapter 10
Cache in TimesTen Works With Synchronous Data Guard
dbms_service.start_service('DBSERV');
END IF;
END;
This procedure should be performed first on the physical or logical standby database,
and then on the primary database, right before the switchover process. Before running
the procedure for a physical standby database switchover, Active Data Guard must be
enabled on the physical standby database.
Before performing a switchover to a logical standby database, stop the Oracle Database
service for TimesTen on the primary database and disconnect all sessions connected to that
service. Then start the service on the standby database.
At this point, cache applications try to reconnect to the standby database. If a switchover
occurs, there is no wait required to migrate the connections from the primary database to the
standby database. This eliminates the performance impact on TimesTen and its applications.
1. Create an Oracle Net service name that includes all primary and standby hosts in
ADDRESS_LIST. For example:
DBSERV =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = PRIMARYDB)(PORT = 1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = STANDBYDB)(PORT = 1521))
(LOAD_BALANCE = yes)
)
(CONNECT_DATA= (SERVICE_NAME=DBSERV))
)
10-15
11
Using GoldenGate as an Alternative to Native
Read-Only Cache Groups
Oracle GoldenGate is Oracle's primary data replication and data exchange technology.
GoldenGate supports a multitude of databases as sources for data capture as well as targets
for data delivery.
TimesTen can be deployed in several ways, including as an in-memory cache for data that
resides in an Oracle database. TimesTen provides functionality to enable it to act as a cache
for Oracle database. This technology supports both read-only and read-write caching.
If your caching use case is to provide read-only caching, then (in some cases) you may
prefer to use GoldenGate to refresh data from the back-end database to the TimesTen cache,
instead of using the TimesTen native cache functionality.
Note:
While this chapter refers to using GoldenGate for cache refresh, the operation is
more accurately identified as unidirectional real-time replication. For the use case
described in this document, this distinction is mostly irrelevant.
Note:
The Oracle GoldenGate Documentation is the definitive source for information on
GoldenGate installation, configuration, and operation. See Using Oracle
GoldenGate With TimesTen in the Using Oracle GoldenGate for Heterogeneous
Databases guide for a description of features supported and guidelines for
preparing the system to support cache refresh using Oracle GoldenGate. This
chapter does not duplicate significant information from the GoldenGate
documentation, except where it is pertinent to do so.
The following sections describe when and how to use GoldenGate as the cache refresh
mechanism for TimesTen:
• TimesTen and GoldenGate Support for Cache Refresh
• Considerations When Using GoldenGate as the Cache Refresh Mechanism
• Configuring GoldenGate to Provide Cache Refresh Functionality for TimesTen
• Example of Caching Using GoldenGate
11-1
Chapter 11
Considerations When Using GoldenGate as the Cache Refresh Mechanism
The installed TimesTen version is 18.1.4.9.0 or higher and the installed GoldenGate
version is 19.1 or higher.
The GoldenGate parallel Replicat process, which can improve replication throughput in
some use cases, is supported with GoldenGate 21.3 and higher.
Use GoldenGate release 21.3 or later for the best experience.
11-2
Chapter 11
Configuring GoldenGate to Provide Cache Refresh Functionality for TimesTen
• GoldenGate is a separately licensed product, and you must have suitable licenses to
cover your usage. You must have license coverage for both GoldenGate capture for the
source database and GoldenGate apply for TimesTen.
11-3
Chapter 11
Configuring GoldenGate to Provide Cache Refresh Functionality for TimesTen
• The actions required for steps (1) through (3) above have been correctly carried
out. This chapter does not cover these steps since they are covered in detail in the
GoldenGate documentation and by many other online sources and articles.
• This chapter primarily focuses on steps (4) through (10).
11-4
Chapter 11
Configuring GoldenGate to Provide Cache Refresh Functionality for TimesTen
Client-Server Connectivity
TimesTen client-server mode provides regular client-server connectivity through TCP/IP
connections.
The applications can run anywhere that has suitable network connectivity to the host where
TimesTen is running. Client-server potentially offers more flexibility than direct mode, but this
flexibility comes at the cost of increased overhead and lower performance due to network
latency, additional processing, and so on.
Note:
If you already have a suitable TimesTen instance and database that is configured
for connectivity to the source Oracle database, then you can skip this step.
1. Prepare an Oracle Database Net Services tnsnames.ora file with a suitable TNS entry to
enable connectivity from the TimesTen host system to the source Oracle database. Save
this file in a suitable directory.
The following example creates a TNS entry called myoradb:
MYORADB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oradb.example.net)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = myoradb)
)
)
2. Set the TNS_ADMIN location for the cache agent with the ttInstanceModify -tnsadmin
option to set the path to the tnsnames.ora file. Specify the full path to the directory where
the file is located.
ttInstanceModify -tnsadmin /TimesTen/conf
3. For cache in TimesTen Classic, set the TNS_ADMIN environment variable to indicate the
full path to the directory where the tnsnames.ora file is located. Set this variable in the
user's profile script so that it persists.
export TNS_ADMIN=/TimesTen/tnsadmin
5. Prepare the host where both TimesTen and the target database will reside. Install
TimesTen and create a TimesTen instance. When creating the instance, enable the
instance to use the TNS_ADMIN value that it can detect from the environment. See
11-5
Chapter 11
Configuring GoldenGate to Provide Cache Refresh Functionality for TimesTen
[myappdb]
DataStore=/disk1/db/ckpt/myappdb
LogDir=/disk2/db/log
PermSize=8192
TempSize=512
LogBufMB=1024
LogFileSize=1024
MemoryLock=4
DatabaseCharacterSet=AL32UTF8
ConnectionCharacterSet=AL32UTF8
OracleNetServiceName=myoradb
7. While logged in as the TimesTen instance administration user, set the environment
for the TimesTen instance. Connect to the DSN using the ttIsql utility, which
creates the target database.
11-6
Chapter 11
Configuring GoldenGate to Provide Cache Refresh Functionality for TimesTen
3. GoldenGate for Oracle TimesTen supports delivery of data to user tables, instead of
cache groups. Since GoldenGate uses regular tables instead of cache groups, create
your cache tables in TimesTen as regular tables (using the CREATE TABLE statement) and
not as cache groups (using the CREATE READONLY CACHE GROUP statement).
This step creates the required cache tables in TimesTen. Make sure that the table
definitions are compatible with the corresponding tables in the source database. You
should create the tables owned by the ggapply database user (you need to be connected
either as ggapply or as some other user with ADMIN privileges):
CREATE TABLE ggapply.cachetab1 ( … );
CREATE TABLE ggapply.cachetab2 ( … );
…
4. When using GoldenGate as the cache refresh mechanism, any read-only cached tables
in TimesTen are not truly read-only. Applications are not prevented from modifying data in
the tables (provided that they have suitable access privileges on the tables). However,
any such modifications can be overwritten if GoldenGate refreshes newly modified data
to the table from the back-end database. You can mitigate this by ensuring that
application users only have read access to the cache tables. These tables must be
owned by a user other than the application users, such as the dedicated GoldenGate
apply database user to ensure that the GoldenGate apply process to write to these same
tables.
Grant SELECT (read) privileges on the cache tables to the application users:
GRANT SELECT ON ggapply.cachetab1 TO appuser1, appuser2, …;
GRANT SELECT ON ggapply.cachetab2 TO appuser1, appuser2, …;
5. Generally, for convenience and transparency, each application user may want to have a
private synonym for the application tables that it needs to query to avoid having to always
qualify the table name with the name of the dedicated GoldenGate apply database user
ggapply user. For example:
CREATE SYNONYM appuser1.cachetab1 FOR ggapply.cachetab1;
CREATE SYNONYM appuser2.cachetab1 FOR ggapply.cachetab1;
CREATE SYNONYM appuser1.cachetab2 FOR ggapply.cachetab2;
CREATE SYNONYM appuser2.cachetab2 FOR ggapply.cachetab2;
11-7
Chapter 11
Configuring GoldenGate to Provide Cache Refresh Functionality for TimesTen
systems. Port 6625 on the server must not be blocked by a firewall. Note the setting
for ConnectionCharacterSet.
[ODBC Data Sources]
myappdbcs=TimesTen 22.1 Client Driver
[myappdbcs]
TTC_SERVER=myttserver.example.com/6625
TTC_SERVER_DSN=myappdb
ConnectionCharacterSet=AL32UTF8
3. Login to your TimesTen database using the DBLOGIN command. If you are using
off-box deployment, use the client DSN; otherwise, use the server DSN. The
following example uses the server DSN of myappdb.
DBLOGIN SOURCEDB myappdb, USERID ggapply, PASSWORD ggapply_users_password
4. Create the GoldenGate checkpoint table. This is required for using a GoldenGate
Replicat process with TimesTen. Choose a table name so that it does not conflict
with your application tables:
ADD CHECKPOINTTABLE ggapply.checkpoint_table_name
The trail_name is the name of the remote trail that you specified for either the
data pump or Extract process on the source server.
6. Create a parameter file for the Replicat group. In our example, this file should be
gg_home/dirprm/REP.prm:
REPLICAT rep
TARGETDB myappdb, USERID ggapply, PASSWORD ggapply_users_password
BATCHSQL
MAP oraowner.sourcetab1, TARGET ggapply.cachetab1;
MAP oraowner.sourcetab2, TARGET ggapply.cachetab2;
…
Here oraowner.sourcetab1 is the table owner and name on the source database,
and ggapply.cachetab1 is the table owner and name in the TimesTen database.
Usually the table name is the same in both the source and the target, but this is
not a requirement. You can specify multiple MAP directives or use wildcards for
multiple tables.
11-8
Chapter 11
Configuring GoldenGate to Provide Cache Refresh Functionality for TimesTen
For off-box deployment, use the client DSN instead of the server DSN. You can also use
a GoldenGate credential store and USERIDALIAS for password encryption. For more
information, see Using Oracle GoldenGate with Oracle Database.
If you are using a parallel Replicat process include the following line before the MAP
statements:
APPLY_PARALLELISM 4
You can experiment with the number of apply threads to see which value provides the
most optimal throughput in your environment.
Add any other parameters in this file that apply to your database environment.
Note:
When using TimesTen native caching, one option you have is to cache a subset of
a table (specific columns and/or rows). This is also possible with GoldenGate, but
these details are not covered in this document.
11-9
Chapter 11
Configuring GoldenGate to Provide Cache Refresh Functionality for TimesTen
The following example connects to the TimesTen database with the ggapply user
that was created earlier:
ttIsql -connStr "DSN=myappdb;UID=ggaply;PWD=tt_pwd;OraclePWD=ora_pwd"
4. The initial table data load is used to establish data synchronization when
instantiating GoldenGate replication. To achieve the best performance for the initial
table data load:
• Use the TimesTen ttLoadFromOracle built-in procedure for the initial table
data load if the backend database is an Oracle database. See
ttLoadFromOracle in the Oracle TimesTen In-Memory Database Reference.
• Use the TimesTen ttBulkCp utility for the initial table data load if the backend
database is a non-Oracle database. Export the table data in CSV format and
then load it into TimesTen using the ttBulkCP utility. See ttBulkCp in the
Oracle TimesTen In-Memory Database Reference.
Load the data for each of the GoldenGate target tables using the TimesTen
ttLoadFromOracle built-in procedure, specifying a flashback query targeting the
SCN value determined in step (2) above. For example:
call ttLoadFromOracle('ggapply', 'cachetab1', 'SELECT * FROM
oraowner.sourcetab1 AS OF SCN 12345678');
call ttLoadFromOracle('ggapply', 'cachetab2', 'SELECT * FROM
oraowner.sourcetab2 AS OF SCN 12345678');
…
Note:
If there are no dependencies (such as foreign key constraints) between
tables, then you can load them in parallel using separate ttIsql sessions.
Provided that resources are not a constraint, this can reduce the time
required for the initial data load.
You have now populated the TimesTen cache tables with data from the source Oracle
database. For more information, see Loading Data From an Oracle Database Into a
TimesTen Table in the Oracle TimesTen In-Memory Database Operations Guide.
Note:
GoldenGate refers to this value as a CSN (Commit Sequence Number)
rather than an SCN, hence the parameter name AFTERCSN.
You can see the changes are replicated from source database to TimesTen. You can
also check the status of a Replicat process using the following GGSCI command.
11-10
Chapter 11
Example of Caching Using GoldenGate
You now have a working setup that uses GoldenGate to replicate data changes from your
source Oracle database to your TimesTen cache database.
The GoldenGate deployment mode for TimesTen is on-box using direct mode connectivity.
Prerequisites
• A functioning Oracle database is a recent version.
• A recent version of GoldenGate is installed on the Oracle database host.
• A functioning TimesTen instance is running at least TimesTen 22.1.1.1.0.
• GoldenGate 21.3 is installed on the TimesTen host.
• The TimesTen cache database has been configured and created.
• DatabaseCharacterSet and ConnectionCharacterSet correctly set in the TimesTen
database.
There is also an Oracle user named ggapply with password OR-zXy087-TvrQ, which has
SELECT privileges on the tables that are to be cached.
The appuser user owns three tables that will be cached in TimesTen:
CREATE TABLE customer
(
custid VARCHAR2(10) NOT NULL,
firstname VARCHAR2(20) NOT NULL,
lastname VARCHAR2(20) NOT NULL,
address VARCHAR2(128) NOT NULL,
phone VARCHAR2(16) NOT NULL,
PRIMARY KEY (custid)
);
CREATE TABLE order
(
orderid NUMBER(10,0) NOT NULL,
custid VARCHAR2(10) NOT NULL,
orderdate DATE NOT NULL,
priority CHAR(1),
amount NUMBER(12,2) NOT NULL,
PRIMARY KEY (orderid),
FOREIGN KEY (custid) REFERENCES customer(custid)
);
CREATE TABLE item
11-11
Chapter 11
Example of Caching Using GoldenGate
(
itemno NUMBER(4,0) NOT NULL,
orderid NUMBER(10,0) NOT NULL,
itemcode VARCHAR2(10) NOT NULL,
quantity NUMBER(4,0) NOT NULL,
price NUMBER(6,2) NOT NULL,
totalvalue NUMBER(10,2) NOT NULL,
PRIMARY KEY (orderid,itemno),
FOREIGN KEY (orderid) REFERENCES order(orderid)
);
INSERT INTO customer VALUES('C000000001', 'Fred', 'Bloggs', 'Nice Villas,
Pleasant Town', '+16072321234');
INSERT INTO order VALUES(123456, 'C000000001', '21/10/2021', 'N', 430.46);
INSERT INTO item VALUES(1, 123456, 'I000001725', 2, 15.25, 30.50);
INSERT INTO item VALUES(2, 123456, 'I000207351', 4, 99.99, 399.96);
COMMIT;
1. To create these users in your TimesTen database, connect, using the ttIsql utility,
to the TimesTen database as the instance administrator user and execute:
CREATE USER appuser IDENTIFIED BY TT-app123-XyZ;
GRANT CREATE SESSION, CREATE SYNONYM TO appuser;
CREATE USER ggapply IDENTIFIED BY GG-912-azq;
GRANT CREATE SESSION, CREATE TABLE TO ggapply;
2. Create the target tables in the TimesTen database. Make the tables owned by the
user ggapply, not the application user (appuser). Connect to the database, using
ttIsql, as the user ggapply:
ttIsql -connStr "DSN=ecommerce;UID=ggapply;PWD=GG-912-azq"
3. Execute the following SQL statements to create the tables and grant the
necessary permissions:
CREATE TABLE customer
(
custid VARCHAR2(10) NOT NULL,
firstname VARCHAR2(20) NOT NULL,
lastname VARCHAR2(20) NOT NULL,
address VARCHAR2(128) NOT NULL,
11-12
Chapter 11
Example of Caching Using GoldenGate
4. Connect as the user appuser and create synonyms for the tables:
ttIsql -connStr "DSN=ecommerce;UID=appuser; TT-app123-XyZ "
CREATE SYNONYM customer FOR ggapply.customer;
CREATE SYNONYM order FOR ggapply.order;
CREATE SYNONYM item FOR ggapply.item;
2. Start the GGSCI utility. Assuming that the GoldenGate home directory is in the $GG_HOME
directory:
cd $GG_HOME
./ggsci
11-13
Chapter 11
Example of Caching Using GoldenGate
start manager
5. Start the GoldenGate Extract process using the file you configured above:
start tt
2. Start the GGSCI utility. Assuming that the GoldenGate home directory is in
the $GG_HOME directory:
cd $GG_HOME
./ggsci
4. Login to the TimesTen database, create the GoldenGate checkpoint table and
configure a Replicat group:
DBLOGIN SOURCEDB ecommerce, USERID ggapply, PASSWORD GG-912-azq
ADD CHECKPOINTTABLE ggapply.gg_ckpt_table
ADD REPLICAT rep, EXTTRAIL dirdat/tr, PARALLEL, CHECKPOINTTABLE
ggapply.gg_ckpt_table
CURRENT_SCN
-----------
2791297
11-14
Chapter 11
Example of Caching Using GoldenGate
2. On the host with the TimesTen database, connect to the TimesTen database as the
ggapply user specifying both the TimesTen and Oracle database passwords for this user:
ttIsql -connStr "DSN=ecommerce;UID=ggaply;PWD= GG-912-azq;
OraclePWD=OR-zXy087-TvrQ
3. Load the data for each of the tables based on the Oracle database SCN value
determined above:
call ttLoadFromOracle('ggapply', 'customer',
'SELECT * FROM appuser.customer AS OF scn 2791297');
call ttLoadFromOracle('ggapply', 'order', 'SELECT * FROM appuser.order
AS OF SCN 2791297');
call ttLoadFromOracle('ggapply', item, 'SELECT * FROM appuser.item
AS OF SCN 2791297');
4. Update the optimizer statistics for the tables that you just loaded to ensure optimal query
plans in TimesTen:
statsupdate customer;
statsupdate order;
statsupdate item;
quit;
11-15
A
Procedure and Privileges for Caching Oracle
Database Data in TimesTen
The following sections provide a quick reference on the steps for creating a cache
environment as well as the privileges required to do so:
• Quick Reference to Cache Oracle Database Data in TimesTen
• Required Privileges for Cache Operations
A-1
Appendix A
Quick Reference to Cache Oracle Database Data in TimesTen
within the DSN. In TimesTen Scaleout, these can be specified in either the
database definition or in a connectable.
a. Set the OracleNetServiceName connection attribute to the Oracle Net service
name that references the Oracle database instance.
b. Set the DatabaseCharacterSet connection attribute to the Oracle database
character set. The TimesTen database character set must match the Oracle
database character set.
See Specify Database Connection Definition for Cache.
2. Create the following users in the TimesTen database:
• TimesTen cache administration user
This user must have the same name as a companion Oracle cache
administration user that can access the cached Oracle Database tables. The
password of the TimesTen cache administration user and the companion
Oracle cache administration user can be different.
• One or more cache table users who own the TimesTen cache tables
These users must have the same name as the Oracle Database schema
users who own the cached Oracle Database tables. The password of a cache
table user and the Oracle Database user with the same name can be different.
Run CREATE USER statements as the instance administrator.
See Create the TimesTen Users.
3. Grant the TimesTen cache administration user the privileges required to create the
desired types of cache groups and perform operations on the cache groups. Run
GRANT statements as the instance administrator.
See Required Privileges for Cache Operations.
4. Set the Oracle cache administration user name and password in the TimesTen
database.
See Set the Cache Administration User Name and Password.
5. Start the cache agent on the TimesTen database.
See Managing the Cache Agent.
6. Design the schema for the cache groups by determining which Oracle Database
tables to cache and within those tables, which columns and rows to cache. For
multiple table cache groups, determine the relationship between the tables by
defining which table is the root table, which tables are direct child tables of the root
table, and which tables are the child tables of other child tables. For each cached
column, determine the TimesTen data type to which the Oracle Database data
type should be mapped.
See Mappings Between Oracle Database and TimesTen Data Types.
For each cache group, determine what type to create (read-only, SWT, AWT, or
user managed) based on the application requirements and objectives. Also,
determine whether each cache group is to be static or dynamic.
Then, create the cache groups. See Creating a Cache Group.
7. For TimesTen Classic, if this TimesTen database is intended to be an active
database of an active standby pair, create an active standby pair replication
A-2
Appendix A
Required Privileges for Cache Operations
scheme in the database. See Defining an Active Standby Pair Replication Scheme in the
Oracle TimesTen In-Memory Database Replication Guide.
8. For TimesTen Classic, if the TimesTen database contains an active standby pair
replication scheme or at least one AWT cache group, start the replication agent on the
database either by calling the ttRepStart built-in procedure as the TimesTen cache
administration user or running a ttAdmin -repStart utility command as a TimesTen
external user with the CACHE_MANAGER privilege.
See Starting and Stopping the Replication Agent.
9. Manually load the cache tables in static cache groups using LOAD CACHE GROUP
statements, and load the cache tables in dynamic cache groups using proper SELECT,
UPDATE or INSERT statements.
See Manually Loading and Refreshing a Cache Group and Dynamic Cache Groups.
Table A-1 Oracle Database and TimesTen User Privileges Required for Cache Operations
A-3
Appendix A
Required Privileges for Cache Operations
Table A-1 (Cont.) Oracle Database and TimesTen User Privileges Required for Cache
Operations
A-4
Appendix A
Required Privileges for Cache Operations
Table A-1 (Cont.) Oracle Database and TimesTen User Privileges Required for Cache
Operations
A-5
Appendix A
Required Privileges for Cache Operations
Table A-1 (Cont.) Oracle Database and TimesTen User Privileges Required for Cache
Operations
A-6
Appendix A
Required Privileges for Cache Operations
Table A-1 (Cont.) Oracle Database and TimesTen User Privileges Required for Cache
Operations
A-7
Appendix A
Required Privileges for Cache Operations
Table A-1 (Cont.) Oracle Database and TimesTen User Privileges Required for Cache
Operations
A-8
Appendix A
Required Privileges for Cache Operations
Table A-1 (Cont.) Oracle Database and TimesTen User Privileges Required for Cache
Operations
A-9
Appendix A
Required Privileges for Cache Operations
Table A-1 (Cont.) Oracle Database and TimesTen User Privileges Required for Cache
Operations
A-10
Appendix A
Required Privileges for Cache Operations
Table A-1 (Cont.) Oracle Database and TimesTen User Privileges Required for Cache
Operations
A-11
Appendix A
Required Privileges for Cache Operations
Table A-1 (Cont.) Oracle Database and TimesTen User Privileges Required for Cache
Operations
1 At minimum, the Oracle cache administration user must have the CREATE TYPE privilege.
2 At minimum, the TimesTen cache administration user must have the CREATE SESSION privilege.
3 If the Oracle cache administration user will not create cache groups with autorefresh, then you can grant the CREATE
TRIGGER privilege instead of the CREATE ANY TRIGGER privilege.
4 Required if the cache agent start policy is being set to always or norestart.
5 Required on all Oracle Database tables cached in the TimesTen cache group except for tables owned by the Oracle cache
administration user.
6 The CACHE_MANAGER privilege includes the CREATE [ANY] CACHE GROUP privilege. ANY is required if the TimesTen
cache administration user creates cache groups owned by a user other than itself.
7 ANY is required if any of the cache tables are owned by a user other than the TimesTen cache administration user.
8 Required if the cache group's autorefresh mode is incremental and initial autorefresh state is OFF, and the Oracle Database
objects used to manage the caching of Oracle Database data are automatically created.
9 Required if the TimesTen user accessing the cache group does not own the cache group.
1 Required if the cache group's autorefresh mode is incremental.
0
1 Required if the TimesTen user accessing the cache group does not own all its cache tables.
1
1 The privilege must be granted to the Oracle Database user with the same name as the TimesTen cache administration user if
2 the Oracle Database user is not the Oracle cache administration user.
1 Required if the TimesTen user accessing the cache table does not own the table.
3
A-12
B
SQL*Plus Scripts for Cache
TimesTen is installed with SQL*Plus scripts that are used to perform various cache
configuration, administrative and monitoring tasks, and provide links to more information
including examples.
All scripts are installed in the timesten_home/install/oraclescripts directory.
B-1
C
Compatibility Between TimesTen and Oracle
Databases
The following sections list compatibility issues between TimesTen and Oracle Databases. The
list is not complete, but it indicates areas that require special attention.
• Summary of Compatibility Issues
• Transaction Semantics
• API Compatibility
• SQL Compatibility
• Mappings Between Oracle Database and TimesTen Data Types
Transaction Semantics
TimesTen and Oracle Database transaction semantics differ in a few ways.
• Oracle Database serializable transactions can fail at commit time because the transaction
cannot be serialized. TimesTen uses locking to enforce serializability.
• Oracle Database can provide both statement-level and transaction-level consistency by
using a multi-version consistency model. TimesTen does not provide statement-level
consistency. TimesTen provides transaction-level consistency by using serializable
isolation.
• Oracle Database users can lock tables manually through SQL. This locking feature is not
supported in TimesTen.
• Oracle Database supports savepoints while TimesTen does not.
C-1
Appendix C
API Compatibility
API Compatibility
There are methods from the JDBC and ODBC APIs that have a compatibility issue
with cache.
The following sections list methods from the JDBC and ODBC APIs that have a
compatibility issue with cache.
• JDBC API Compatibility
• ODBC API Compatibility
java.sql.Connection
The following Connection methods have no compatibility issues:
close()
commit()
createStatement()
prepareCall()
prepareStatement()
rollback()
setAutoCommit()
C-2
Appendix C
API Compatibility
Note:
See Transaction Semantics for restrictions for the get/setTransactionIsolation()
methods.
The isClosed() method returns only the TimesTen connection status.
java.sql.Statement
The following Statement methods have no compatibility issues:
addBatch()
clearBatch()
close()
execute()
executeBatch()
executeQuery()
executeUpdate()
getResultSet()
getUpdateCount()
getWarnings()
java.sql.ResultSet
The following ResultSet methods have no compatibility issues:
close()
findColumn(int) and findColumn(string)
getXXX(number) and getXXX(name)
getXXXStream(int) and getXXXStream(string)
getMetaData()
java.sql.PreparedStatement
The following PreparedStatement methods have no compatibility issues:
addBatch()
close()
execute()
executeUpdate()
executeQuery()
getResultSet()
getUpdateCount()
setXXX()
setXXXStream()
C-3
Appendix C
API Compatibility
java.sql.CallableStatement
The same restrictions as shown for the java.sql.Statement and
java.sql.PreparedStatement interfaces apply to CallableStatement.
java.sql.ResultSetMetaData
The following ResultSetMetaData methods have no compatibility issues:
getColumnCount()
getColumnType()
getColumnLabel()
getColumnName()
getTableName()
isNullable()
Stream Support
There are compatibility issues related to streams.
The compatibility issues related to streams are:
C-4
Appendix C
SQL Compatibility
• The JDBC driver fully fetches the data into an in-memory buffer during a call to the
executeQuery() or next() methods. The getXXXStream() entry points return a stream
that reads data from this buffer.
• Oracle supports up to 2 GB of long or long raw data. When cached, TimesTen converts
LONG data into VARCHAR2 data. TimesTen converts LONG RAW data into VARBINARY data.
Both VARCHAR2 and VARBINARY data types can store up to a maximum 4,194,304 (222)
bytes).
• Oracle always streams LONG/LONG RAW data even if the application does not call
getXXXStream().
• TimesTen does not support the mark(), markSupported(), and reset() methods.
SQL Compatibility
This section compares TimesTen's SQL implementation with Oracle Database SQL.
The purpose is to provide users with a list of Oracle Database SQL features not supported in
TimesTen or supported with different semantics.
• Schema Objects
• Non-Schema Objects
• Differences Between Oracle Database and TimesTen Tables
• Data Type Support
C-5
Appendix C
SQL Compatibility
• SQL Operators
• SELECT Statements
• SQL Subqueries
• SQL Functions
• SQL Expressions
• INSERT/DELETE/UPDATE/MERGE Statements
• TimesTen-Only SQL and Built-In Procedures
• PL/SQL Constructs
Schema Objects
TimesTen does not recognize some of the schema objects that are supported in
Oracle Database.
TimesTen returns a syntax error when a statement manipulates or uses these objects.
TimesTen passes the statement to Oracle Database. The unsupported objects are:
Clusters
Objects created by the CREATE DATABASE statement
Objects created by the CREATE JAVA statement
Database links
Database triggers
Dimensions
Extended features
External procedure libraries
Index-organized tables
Mining models
Partitions
Object tables, types and views
Operators
TimesTen supports views and materialized views, but it cannot cache an Oracle
Database view. TimesTen can cache an Oracle Database materialized view in a user-
managed cache group without the AUTOREFRESH cache group attribute and PROPAGATE
cache table attribute. The cache group must be manually loaded and flushed.
C-6
Appendix C
SQL Compatibility
Non-Schema Objects
TimesTen does not recognize some of the schema objects that are supported in Oracle
Database.
TimesTen returns a syntax error when a statement manipulates or uses these objects.
TimesTen passes the statement to Oracle Database. The unsupported objects are:
Contexts
Directories
Editions
Restore points
Roles
Rollback segments
Tablespaces
C-7
Appendix C
SQL Compatibility
TT_DECIMAL
TT_DATE
TIME and TT_TIME
TT_TIMESTAMP
Note:
TimesTen NCHAR and NVARCHAR2 data types are encoded as UTF-16. Oracle
Database NCHAR and NVARCHAR2 data types are encoded as either UTF-16 or
UTF-8.
To cache an Oracle Database NCHAR or NVARCHAR2 column, the Oracle
Database NLS_NCHAR_CHARACTERSET encoding must be AL16UTF16, not
AL32UTF8.
SQL Operators
TimesTen supports a subset of operators and predicates that are supported by the
Oracle Database:
unary -
+, -, *, /
=, <, >, <=, >=, <>, !=
||
IS NULL, IS NOT NULL
LIKE (Oracle Database LIKE operator ignores trailing spaces, but TimesTen does
not)
BETWEEN
IN
NOT IN (list)
AND
OR
+ (outer join)
ANY, SOME
ALL (list)
EXISTS
UNION
MINUS
INTERSECT
To run a bitwise AND operation of two bit vector expressions, TimesTen uses the
ampersand character (&) between the expressions while Oracle Database uses the
BITAND function with the expressions as arguments.
C-8
Appendix C
SQL Compatibility
SELECT Statements
TimesTen supports a subset of clauses of a SELECT statement that are supported by the
Oracle Database:
• FOR UPDATE
• ORDER BY, including NULLS FIRST and NULLS LAST
• GROUP BY, including ROLLUP, GROUPING_SETS and grouping expression lists
• Table alias
• Column alias
• Subquery factoring clause with constructor
Oracle Database supports flashback queries, which are queries against a database that is in
some previous state (for example, a query on a table as of yesterday). TimesTen does not
support flashback queries.
TimesTen does not support the CONNECT BY clause.
SQL Subqueries
TimesTen supports a subset of subqueries that are supported by the Oracle Database.
IN (subquery)
>,<,= ANY (subquery)
>,=,< SOME (subquery)
EXISTS (subquery)
>,=,< (scalar subquery)
Subqueries in WHERE clause of DELETE/UPDATE
Subqueries in FROM clause
Subquery factoring clause (WITH constructor)
Note:
A nonverifiable scalar subquery is a scalar subquery whose 'single-row-result-set'
property cannot be determined until runtime. TimesTen allows at most one
nonverifiable scalar subquery in the entire query and the subquery cannot be
specified in an OR expression.
SQL Functions
TimesTen supports a subset of functions that are supported by the Oracle Database.
ABS
ADD_MONTHS
ASCIISTR
AVG
CAST
C-9
Appendix C
SQL Compatibility
CEIL
COALESCE
CONCAT
COUNT
CHR
DECODE
DENSE_RANK
EMPTY_BLOB
EMPTY_CLOB
EXTRACT
FIRST_VALUE
FLOOR
GREATEST
GROUP_ID
GROUPING
GROUPING_ID
INSTR
LAST_VALUE
LEAST
LENGTH
LOWER
LPAD
LTRIM
MAX
MIN
MOD
MONTHS_BETWEEN
NCHR
NLS_CHARSET
NLS_CHARSET_NAME
NLSSORT
NULLIF
NUMTOYMINTERVAL
NUMTODSINTERVAL
NVL
POWER
RANK
REPLACE
ROUND
ROW_NUMBER
RPAD
RTRIM
SIGN
SQRT
SUBSTR
SUM
SYS_CONTEXT
SYSDATE
TO_BLOB
C-10
Appendix C
SQL Compatibility
TO_CLOB
TO_CHAR
TO_DATE
TO_LOB
TO_NCLOB
TO_NUMBER
TRIM
TRUNC
UID
UNISTR
UPPER
USER
TimesTen and the Oracle Database interpret the literal N'\UNNNN' differently. In TimesTen,
N'\unnnn' (where nnnn is a number) is interpreted as the national character set character
with the code nnnn. In the Oracle Database, N'\unnnn' is interpreted as 6 literal characters.
The \u is not treated as an escape. This difference causes unexpected behavior. For
example, loading a cache group with a WHERE clause that contains a literal can fail. This can
also affects dynamic loading. Applications should use the UNISTR SQL function instead of
literals.
SQL Expressions
TimesTen supports a subset of expressions that are supported by the Oracle Database.
Column Reference
Sequence
NULL
()
Binding parameters
CASE expression
ROWID pseudocolumn
ROWNUM pseudocolumn
TimesTen and Oracle Database treat literals differently. See the description of
HexadecimalLiteral in Constants in Oracle TimesTen In-Memory Database SQL Reference.
C-11
Appendix C
SQL Compatibility
INSERT/DELETE/UPDATE/MERGE Statements
TimesTen supports certain DML statements that are also supported by the Oracle
Database.
• INSERT INTO ... VALUES
• INSERT INTO ... SELECT
• UPDATE WHERE expression (expression may contain a subquery)
• DELETE WHERE expression (expression may contain a subquery)
TimesTen does not support updating of primary key values except when the new value
is the same as the old value.
Note:
For more details on TimesTen support for unicode strings, see Character
and Unicode Strings in the Oracle TimesTen In-Memory Database
Reference.
– Supplying \046 converts to the & symbol on TimesTen, but is not converted to
this symbol when passed through to an Oracle database. The \xyz notation is
not supported by the Oracle database. To send a character through to an
Oracle database, pass it as an argument within the CHR() function with the
decimal value of the character.
C-12
Appendix C
Mappings Between Oracle Database and TimesTen Data Types
PL/SQL Constructs
TimesTen supports a subset of stored procedure constructs, functions, data types, packages
and package bodies that are supported by Oracle Database.
See Overview of PL/SQL Features in the Oracle TimesTen In-Memory Database PL/SQL
Developer's Guide.
Note:
TimeTen cache, including passthrough, does not support the Oracle Database
ROWID data type. However, you can cast a ROWID data type to a CHAR(18) when
provided on the SELECT list in a SQL query.
The following example demonstrates the error that is returned when you do not cast
the ROWID data type. Then, the example shows the correct casting of a ROWID data
type to CHAR(18):
Command> SET PASSTHROUGH 3;
Passthrough command has set autocommit off.
Command> SELECT ROWID FROM dual;
5115: Unsupported type mapping for column ROWID
The command failed.
Command> SELECT CAST (ROWID AS CHAR(18)) FROM DUAL;
< AAAAB0AABAAAAEoAAA >
1 row found.
Primary and foreign key columns are distinguished from non-key columns. The data type
mappings allowed for key columns in a cache table are shown in Table C-2.
C-13
Appendix C
Mappings Between Oracle Database and TimesTen Data Types
Table C-3 shows the data type mappings allowed for non-key columns in a cache
table.
C-14
Appendix C
Mappings Between Oracle Database and TimesTen Data Types
Table C-3 (Cont.) Data Type Mappings Allowed for Non-Key Columns
C-15
Appendix C
Mappings Between Oracle Database and TimesTen Data Types
Table C-3 (Cont.) Data Type Mappings Allowed for Non-Key Columns
C-16