LOAD CACHE GROUP
The LOAD CACHE GROUP statement loads data from Oracle database tables into a TimesTen cache group.
Required Privilege
No privilege is required for the cache group owner.
LOAD or LOAD ANY CACHE GROUP for another user's cache group.
INSERT, DELETE, UPDATE privileges on underlying tables.
Usage with TimesTen Scaleout
This statement is supported with TimesTen Scaleout.
SQL Syntax
LOAD CACHE GROUP [Owner.]GroupName [WHERE ConditionalExpression] COMMIT EVERY n ROWS [PARALLEL NumThreads [READERS NumReaders]]
or
LOAD CACHE GROUP [Owner.]GroupName WITH ID (ColumnValueList)
Note:
TheWITH ID clause is not supported in TimesTen Scaleout.
Parameters
| Parameter | Description |
|---|---|
|
|
Name assigned to the cache group. |
|
|
Use the |
|
|
Use the
|
|
|
Provides parallel loading for cache group tables. Specifies the number of loading threads to run concurrently. One thread performs the bulk fetch from the Oracle database and the other threads ( The minimum value for |
|
|
This option specifies the total number of threads from the For example, if you specify a Express |
|
|
The The |
Description
-
LOAD CACHE GROUPloads all new cache instances from the Oracle database that satisfy the cache group definition and are not yet present in the cache group. -
Before issuing the
LOAD CACHE GROUPstatement, ensure that the replication agent is running if the cache group is replicated or is an AWT cache group. Make sure the cache agent is running. -
LOAD CACHE GROUPis executed in its own transaction, and must be the first operation in a transaction. -
LOAD CACHE GROUPonly loads new (inserted) rows on the Oracle database tables into the corresponding TimesTen cache tables. -
Errors cause a rollback. When cache instances are committed periodically, errors abort the remainder of the load. The load is rolled back to the last commit.
-
If the
LOAD CACHE GROUPstatement fails when you specifyCOMMIT EVERYnROWS(wheren>= 0), the content of the target cache group could be in an inconsistent state since some loaded rows are already committed. Some cache instances may be partially loaded. Use theUNLOAD CACHE GROUPstatement to unload the cache group, then reload the cache group. -
Generally, you do not have to fully qualify the column names in the
WHEREclause of theLOAD CACHE GROUPstatement. However, since TimesTen automatically generates queries that join multiple tables in the same cache group, a column must be fully qualified if there is more than one table in the cache group that contains columns with the same name. -
When loading a read-only cache group:
-
The
AUTOREFRESHstate must be paused. -
The
LOAD CACHE GROUPstatement cannot have aWHEREclause (except on a dynamic cache group). -
The cache group must be empty.
-
-
The automatic refresh state of a cache group may change after a
LOADCACHEGROUPoperation completes. See Loading and Refreshing a Dynamic Cache Group with Autorefresh in the Oracle TimesTen In-Memory Database Cache Guide for information. -
Following the execution of a
LOAD CACHE GROUPstatement, the ODBC functionSQLRowCount(), the JDBC methodgetUpdateCount(), and the OCI functionOCIAttrGet()with theOCI_ATTR_ROW_COUNTargument return the number of cache instances that were loaded. -
Use the
WITH IDclause as follows:-
In place of the
WHEREclause for faster loading of the cache instance -
To specify binding parameters
-
To roll back the load transaction upon failure
-
Restrictions
-
The
LOADCACHEGROUP...WITHIDclause is not supported in TimesTen Scaleout.
-
Do not reference child tables in the
WHEREclause. -
Do not specify the
PARALLELclause in the following circumstances:-
With the
WITH IDclause -
With the
COMMIT EVERY 0 ROWSclause -
When database level locking is enabled (connection attribute
LockLevelis set to 1)
-
-
Do not use the
WITH IDclause when loading these types of cache groups:-
Static read-only cache group
-
Static user managed cache group with the autorefresh attribute
-
User managed cache group with the
AUTOREFRESHandPROPAGATEattributes
-
-
Do not use the
WITH IDclause with theCOMMIT EVERYnROWSclause.
Examples
CREATE CACHE GROUP recreation.cache FROM recreation.clubs ( clubname CHAR(15) NOT NULL, clubphone SMALLINT, activity CHAR(18), PRIMARY KEY(clubname)) WHERE (recreation.clubs.activity IS NOT NULL); LOAD CACHE GROUP recreation.cache COMMIT EVERY 30 ROWS;
Use the HR schema to illustrate the use of the PARALLEL clause with the LOAD CACHE GROUP statement. The COMMIT EVERY n ROWS clause is required. Issue the CACHEGROUPS command. You see cache group cg2 is defined and the autorefresh state is paused. Unload cache group cg2, then specify the LOAD CACHE GROUP statement with the PARALLEL clause to provide parallel loading. You see 25 cache instances loaded.
Command> CACHEGROUPS; Cache Group SAMPLEUSER.CG2: Cache Group Type: Read Only Autorefresh: Yes Autorefresh Mode: Incremental Autorefresh State: Paused Autorefresh Interval: 1.5 Minutes Root Table: SAMPLEUSER.COUNTRIES Table Type: Read Only Child Table: SAMPLEUSER.LOCATIONS Table Type: Read Only Child Table: SAMPLEUSER.DEPARTMENTS Table Type: Read Only 1 cache group found. Command> UNLOAD CACHE GROUP cg2; 25 cache instances affected. Command> COMMIT; Command> LOAD CACHE GROUP cg2 COMMIT EVERY 10 ROWS PARALLEL 2; 25 cache instances affected. Command> COMMIT;
The following example loads only the cache instances for customers whose customer number is greater than or equal to 5000 into the TimesTen cache tables in the new_customers cache group from the corresponding Oracle database tables:
LOAD CACHE GROUP new_customers WHERE (oratt.customer.cust_num >= 5000) COMMIT EVERY 256 ROWS;
See also