Development Guide Volume 5: Caching Guide
This guide is intended for developers
Abstract
Chapter 1. Read Me
1.1. Back Up Your Data
Warning
1.2. Variable Name: EAP_HOME
EAP_HOME refers to the root directory of the Red Hat JBoss Enterprise Application Platform installation on which JBoss Data Virtualization has been deployed.
1.3. Variable Name: MODE
MODE will either be standalone or domain depending on whether JBoss Data Virtualization is running in standalone or domain mode. Substitute one of these whenever you see MODE in a file path in this documentation. (You need to set this variable yourself, based on where the product has been installed in your directory structure.)
1.4. Red Hat Documentation Site
Chapter 2. Some Key Definitions
2.1. Result Set Caching
2.2. Internal Materialization
2.3. External Materialization
2.4. Materialized Views
2.5. Materialization Table
2.6. NOCACHE Option
2.7. Results Caching
Chapter 3. Using Caching
3.1. Caching
Note
3.2. Internal Materialization
3.2.1. Use Internal Materialization
Procedure 3.1. Use Internal Materialization
- Build a VDB using the Teiid Designer for your usecase normally.
- Identify all the "Virtual Tables", that you think can use caching, then click on the table.
- In the Properties panel, switch the Materialized property to "true"
Important
3.2.2. Internal Materialization Usage Steps
Table 3.1. Properties
| Property | Description |
|---|---|
teiid_rel:ALLOW_MATVIEW_MANAGEMENT |
Allow Teiid based management of the ttl and initial load rather than the implicit behavior
|
teiid_rel:MATVIEW_PREFER_MEMORY |
Same as the pref_mem cache hint option
|
teiid_rel:MATVIEW_TTL |
Same as the ttl cache hint option
|
teiid_rel:MATVIEW_UPDATABLE |
Same as the updatable cache hint option
|
teiid_rel:MATVIEW_SCOPE |
Same as the scope cache hint option
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<vdb name="sakila" version="1">
<model name="pg">
<source name="pg" translator-name="postgresql" connection-jndi-name="java:/sakila-ds"/>
</model>
<model name="sakila" type="VIRTUAL">
<metadata type="DDL"><![CDATA[
CREATE VIEW actor (
actor_id integer,
first_name varchar(45) NOT NULL,
last_name varchar(45) NOT NULL,
last_update timestamp NOT NULL
) OPTIONS (materialized true, "teiid_rel:MATVIEW_TTL" 120000,
"teiid_rel:MATVIEW_PREFER_MEMORY" 'true',
"teiid_rel:MATVIEW_UPDATABLE" 'true',
"teiid_rel:MATVIEW_SCOPE" 'vdb')
AS SELECT actor_id, first_name, last_name, last_update from pg."public".actor;
</metadata>
</model>
</vdb>CALL SYSADMIN.refreshMatView(viewname=>'schema.matview', invalidate=>true)
Auto-refresh Transformation Query /*+ cache(ttl:3600000) */ select t.col, t1.col from t, t1 where t.id = t1.id
/*+ cache(updatable) */ select t.col, t1.col from t, t1 where t.id = t1.id
CALL SYSADMIN.refreshMatViewRow(viewname=>'schema.matview', key=>5)
Internal materialized view tables will automatically create non-unique indexes for each unique constraint and index defined on the materialized view. These indexes are created as non-unique even for unique constraints since the materialized table is not intended as an enforcement point for data integrity and when updatable the table may not be consistent with underlying values and thus unable to satisfy constraints. The primary key (if it exists) of the view will automatically be part of the covered columns for the index.
3.2.3. Internal Materialization Options
/*+ cache(ttl:300000) */ select * from Source.UpdateProduct
- Loading of materialized contents is automatic when the user query is executed like the one below. (It is assumed for this example that you used the cache hint mentioned above.)
SELECT * FROM Products.UpdateProduct
This will retain the contents of the materialization table for 300000 milliseconds (5 minutes). After the defined cache time expires, any user query like above will see that the cache time has expired and will start a new asynchronous job to load the contents of the view into materialization cache.Important
In this example, the user query started a new refresh/load job. As a default, this invalidates the current results unless the vdb propertylazy-invalidateis set totrue. For details about this property, seeUsing TTL Snapshot Refreshin Section 3.2.2, “Internal Materialization Usage Steps” If this property is set, while the load/refresh job is running, the user queries continue to return the expired results. When the refresh/reload job completes, then the old results will be flushed and new results will be used for any future user requests.The main idea here is not to block user queries while the refresh job is running. This is mainly due to the fact that you can not predict how long a refresh job going to run. This is "implicit" materialization loading, if your use case does not allow this kind of refresh then use below techniques for "explicit" materialization load. - To start a load/refresh job on internal materialized view immediately, launch the "admin-console", go to the Runtime tab, select Virtual Databases, select your VDB, click the Caching tab, Materialized Tables, select your view and click .When you choose to invalidate, then any user queries that come in against this materialization table will be blocked until the cache contents are fully loaded. If the invalidation is not chosen then the behaviour will be the same as that seen in the first option above.
- You can also issue SQL command
"EXEC SYSADMIN.refreshMatView(viewname=>'Portfolio.UpdateTable', invalidate=>true)"from any JDBC query tool or through Admin Shell to clear the contents of materialization table and start the refresh of contents immediately. The same invalidation rules apply here as in the above.This third option has the advantage of allowing you to automate the refresh process via scripting it, so you can run it at frequent intervals.
3.3. External Materialization
3.3.1. Use External Materialization
Procedure 3.2. Use External Materialization
- Build a VDB using the Teiid Designer for your use case.
- Identify all the "Virtual Tables", that you think can use caching,
- Click on the table, then in the Properties panel, switch the Materialized property to "true".
- Right click on each materialized table, then choose - .
- Click on button on the Materialization Model input box.
- Select a "physical model" that already exists or create a new name for "physical model".
- Click .This will create the new model (if applicable) and a table with exact schema as your selected virtual table.
- Verify that the "Materialization Table" property is now updated with name of table that has just been created.
- Navigate to the new materialized table that has been created, and click on "Name In Source" property and change it from "MV1000001" to "mv_{your_table_name}". Typically this could be same name as your virtual table name, (for example, you might name it "mv_UpdateProduct".)
- Save your model.
Note
The data source this materialized view physical model represents will be the data source for storing the materialized tables. You can select different "physical models" for different materialized tables, creating multiple places to store your materialized tables. - Once you are have finished creating all materialized tables, right click on each model (in most cases this will be a single physical model used for all the materialized views), then use - - to generate the DDL for the physical model.
- Select the type of the database and DDL file name and click .A DDL file that contains all of the "create table" commands is generated..
- Use your favorite "client" tool for your database and create the database using the DDL file created.
- Go back to your VDB and configure the data source and translator for the "materialized" physical model to the database you just created.
- Once finished, deploy the VDB to Teiid Server and make sure that it is correctly configured and active.
Important
3.3.2. External Materialization Usage Steps
insert into target_table select * from matview option nocache matview
Users when they are designing their views, they can define additional metadata on their views to control the loading and refreshing of external materialization cache. This option provides a limited but a powerful way to manage the materialization views. For this purpose, SYSADMIN Schema model in your VDB defines three stored procedures (loadMatView, updateMatView, matViewStatus) in its schema. Based on the defined metadata on the view, and these SYSADMIN procedures a simple scheduler automatically starts during the VDB deployment and loads and keeps the cache fresh.
CREATE TABLE status ( VDBName varchar(50) not null, VDBVersion integer not null, SchemaName varchar(50) not null, Name varchar(256) not null, TargetSchemaName varchar(50), TargetName varchar(256) not null, Valid boolean not null, LoadState varchar(25) not null, Cardinality long, Updated timestamp not null, LoadNumber long not null, PRIMARY KEY (VDBName, VDBVersion, SchemaName, Name) );
Note
Table 3.2. Extension Properties
| Property | Description | Optional | Default |
|---|---|---|---|
teiid_rel:ALLOW_MATVIEW_MANAGEMENT |
Allow Teiid based management
|
False
|
False
|
teiid_rel:MATVIEW_STATUS_TABLE |
fully qualified Status Table Name defined above
|
False
|
NA
|
teiid_rel:MATVIEW_BEFORE_LOAD_SCRIPT |
semi-colon(;) separated DDL/DML commands to run before the actual load of the cache, typically used to truncate staging table
|
True
|
When not defined, no script will be run
|
teiid_rel:MATVIEW_LOAD_SCRIPT |
semi-colon(;) separated DDL/DML commands to run for loading of the cache
|
True
|
will be determined based on view transformation
|
teiid_rel:MATVIEW_AFTER_LOAD_SCRIPT |
semi-colon(;) separated DDL/DML commands to run after the actual load of the cache. Typically used to rename staging table to actual cache table. Required when MATVIEW_LOAD_SCRIPT is not defined in order to copy data from the teiid_rel:MATVIEW_STAGE_TABLE the MATVIEW table.
|
True
|
When not defined, no script will be run
|
teiid_rel:MATVIEW_SHARE_SCOPE |
Allowed values are {NONE, VDB, SCHEMA}, which define if the cached contents are shared among different VDB versions and different VDBs as long as schema names match
|
True
|
None
|
teiid_rel:MATERIALIZED_STAGE_TABLE |
When MATVIEW_LOAD_SCRIPT property not defined, Teiid loads the cache contents into this table. Required when MATVIEW_LOAD_SCRIPT not defined
|
False
|
NA
|
teiid_rel:ON_VDB_START_SCRIPT |
DML commands to run start of vdb
|
True
|
NA
|
teiid_rel:ON_VDB_DROP_SCRIPT |
DML commands to run at VDB un-deploy; typically used for cleaning the cache/status tables
|
True
|
NA
|
teiid_rel:MATVIEW_ONERROR_ACTION |
Action to be taken when mat view contents are requested but cache is invalid. Allowed values are (THROW_EXCEPTION = throws an exception, IGNORE = ignores the warning and supplied invalidated data, WAIT = waits until the data is refreshed and valid then provides the updated data)
|
True
|
WAIT
|
teiid_rel:MATVIEW_TTL |
time to live in milliseconds. Provide property or cache hint on view transformation - property takes precedence.
|
True
|
2^63 milliseconds - effectively the table will not refresh, but will be loaded a single time initially
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<vdb name="sakila" version="1">
<description>Shows how to call JPA entities</description>
<model name="pg">
<source name="pg" translator-name="postgresql-override" connection-jndi-name="java:/sakila-ds"/>
</model>
<model name="sakila" type="VIRTUAL">
<metadata type="DDL"><![CDATA[
CREATE VIEW actor (
actor_id integer,
first_name varchar(45) NOT NULL,
last_name varchar(45) NOT NULL,
last_update timestamp NOT NULL
) OPTIONS (MATERIALIZED 'TRUE', UPDATABLE 'TRUE',
MATERIALIZED_TABLE 'pg.public.mat_actor',
"teiid_rel:MATERIALIZED_STAGE_TABLE" 'pg.public.mat_actor_staging',
"teiid_rel:ALLOW_MATVIEW_MANAGEMENT" 'true',
"teiid_rel:MATVIEW_STATUS_TABLE" 'pg.public.status',
"teiid_rel:MATVIEW_BEFORE_LOAD_SCRIPT" 'execute pg.native(''truncate table mat_actor_staging'');',
"teiid_rel:MATVIEW_AFTER_LOAD_SCRIPT" 'execute pg.native(''ALTER TABLE mat_actor RENAME TO mat_actor_temp'');execute pg.native(''ALTER TABLE mat_actor_staging RENAME TO mat_actor'');execute pg.native(''ALTER TABLE mat_actor_temp RENAME TO mat_actor_staging;'')',
"teiid_rel:MATVIEW_SHARE_SCOPE" 'NONE',
"teiid_rel:MATVIEW_ONERROR_ACTION" 'THROW_EXCEPTION',
"teiid_rel:MATVIEW_TTL" 300000,
"teiid_rel:ON_VDB_DROP_SCRIPT" 'DELETE FROM pg.public.status WHERE Name=''actor'' AND schemaname = ''sakila''')
AS SELECT actor_id, first_name, last_name, last_update from pg."public".actor;
</metadata>
</model>
<translator name="postgresql-override" type="postgresql">
<property name="SupportsNativeQueries" value="true"/>
</translator>
</vdb>CREATE TABLE status ( VDBName varchar(50) not null, VDBVersion integer not null, SchemaName varchar(50) not null, Name varchar(256) not null, TargetSchemaName varchar(50), TargetName varchar(256) not null, Valid boolean not null, LoadState varchar(25) not null, Cardinality long, Updated timestamp not null, LoadNumber long not null, PRIMARY KEY (VDBName, VDBVersion, SchemaName, Name) );
Note
EmbeddedServer server = new EmbeddedServer();
...
server.addConnectionFactory("name", Object);
...
server.addTranslator("name", ExecutionFactory);
...
EmbeddedConfiguration config = new EmbeddedConfiguration();
config.setTransactionManager(EmbeddedHelper.getTransactionManager());
server.start(config);
...
server.deployVDB("matView-vdb.xml");
CREATE TABLE status( VDBName varchar(50) not null, VDBVersion integer not null, SchemaName varchar(50) not null, Name varchar(256) not null, TargetSchemaName varchar(50), TargetName varchar(256) not null, Valid boolean not null, LoadState varchar(25) not null, Cardinality long, Updated timestamp not null, LoadNumber long not null, PRIMARY KEY (VDBName, VDBVersion, SchemaName, Name) ); CREATE TABLE h2_test_mat( product_id integer, SYMBOL varchar(16) ); CREATE TABLE mat_test_staging( product_id integer, SYMBOL varchar(16) ); CREATE TABLE PRODUCT ( ID integer, SYMBOL varchar(16), COMPANY_NAME varchar(256), CONSTRAINT PRODUCT_PK PRIMARY KEY(ID) ); INSERT INTO PRODUCT (ID,SYMBOL,COMPANY_NAME) VALUES(100,'IBM','International Business Machines Corporation'); INSERT INTO PRODUCT (ID,SYMBOL,COMPANY_NAME) VALUES(101,'DELL','Dell Computer Corporation'); INSERT INTO PRODUCT (ID,SYMBOL,COMPANY_NAME) VALUES(102,'HPQ','Hewlett-Packard Company'); INSERT INTO PRODUCT (ID,SYMBOL,COMPANY_NAME) VALUES(103,'GE','General Electric Company'); INSERT INTO PRODUCT (ID,SYMBOL,COMPANY_NAME) VALUES(104,'SAP','SAP AG'); INSERT INTO PRODUCT (ID,SYMBOL,COMPANY_NAME) VALUES(105,'TM','Toyota Motor Corporation');
<metadata type="DDL">
CREATE VIEW MatView (
product_id integer,
symbol string
)OPTIONS (MATERIALIZED 'TRUE', UPDATABLE 'TRUE',
MATERIALIZED_TABLE 'Accounts.h2_test_mat',
"teiid_rel:MATVIEW_TTL" 20000,
"teiid_rel:MATVIEW_BEFORE_LOAD_SCRIPT" 'execute accounts.native(''truncate table mat_test_staging'');',
"teiid_rel:MATVIEW_AFTER_LOAD_SCRIPT" 'execute accounts.native(''ALTER TABLE h2_test_mat RENAME TO h2_test_mat_temp'');execute accounts.native(''ALTER TABLE mat_test_staging RENAME TO h2_test_mat'');execute accounts.native(''ALTER TABLE h2_test_mat_temp RENAME TO mat_test_staging'');',
"teiid_rel:ON_VDB_DROP_SCRIPT" 'DELETE FROM Accounts.status WHERE Name=''MatView'' AND schemaname = ''Stocks''',
"teiid_rel:MATERIALIZED_STAGE_TABLE" 'Accounts.mat_test_staging',
"teiid_rel:ALLOW_MATVIEW_MANAGEMENT" 'true',
"teiid_rel:MATVIEW_STATUS_TABLE" 'status',
"teiid_rel:MATVIEW_SHARE_SCOPE" 'NONE',
"teiid_rel:MATVIEW_ONERROR_ACTION" 'THROW_EXCEPTION')
AS
SELECT A.ID, A.symbol FROM Accounts.PRODUCT AS A;
</metadata>
</model>
Thread.currentThread().sleep(10 * 1000); // wait loadMatView finish executeQuery(conn, "select * from MatView"); executeUpdate(conn, "INSERT INTO PRODUCT (ID,SYMBOL,COMPANY_NAME) VALUES(2000,'RHT','Red Hat Inc')"); Thread.currentThread().sleep(30 * 1000); // make sure MatView be updated executeQuery(conn, "select * from MatView"); executeUpdate(conn, "DELETE FROM PRODUCT WHERE ID = 2000"); Thread.currentThread().sleep(30 * 1000); // make sure MatView be updated executeQuery(conn, "select * from MatView");
3.3.3. External Materialization Options
INSERT INTO mv_view.mv_UpdateProduct SELECT * FROM Portfolio.UpdateProduct OPTION NOCACHE
sql=connect(${url}, ${user}, ${password});
sql.execute("DELETE FROM mv_view.mv_UpdateProduct");
sql.execute("INSERT INTO mv_view.mv_UpdateProduct SELECT * FROM Portfolio.UpdateProduct OPTION NOCACHE");
sql.close();
adminshell.sh . load.groovy
Note
- If you want to set up a job to run this script frequently at regular intervals, then on Red Hat Enterprise Linux use "cron tab" or on Microsoft Windows use "Windows Scheduler" to refresh the rows in the materialized table. Every time the script runs it will refresh the contents.
- This job needs to be run only when user access is restricted.
Important
- If it is updating all the rows in the materialized table, and you only need to update only few rows to avoid long refresh time.
- If it takes an hour for your reload your materialized table, queries executed during that time will fail to povide correct results.
- Also ensure that you create indexes on your materialization table after the data is loaded, as having indexes during the load process slows down the loading of data, especially when you are dealing with a large number of rows.
3.3.4. Set Up a Staging Table
Procedure 3.3. Set Up a Staging Table
- Build a VDB using the Teiid Designer for your use case.
- Identify all the "Virtual Tables", that you think can use caching,
- Click on the table, then in the Properties panel, switch the Materialized property to "true".
- Right click on each materialized table, then choose - .
- Click on button on the Materialization Model input box.
- Select a "physical model" that already exists or create a new name for "physical model".
- Click .This will create the new model (if applicable) and a table with exact schema as your selected virtual table.
- Verify that the "Materialization Table" property is now updated with name of table that has just been created.
- Navigate to the new table materialized table that has been created, and click on "Name In Source" property.
- Create two identical tables, one with "mv_" prefix and another with "st_" prefix. ("mv_" will stand for materialized view and "st_" will stand for the staging table.)
- Make sure that the "Materialized Table" property is set to the table with "mv_" prefix. Also make sure that both these tables have their "Name in Source" edited and renamed with respective prefixed name.
- Create the DDL file and the database. (The difference now is there are two identical tables for each materialized view.)
- Load the contents into staging table using this query (substitute with the names of your own tables):
INSERT INTO mv_view.ST_UpdateProduct SELECT * FROM Portfolio.UpdateProduct OPTION NOCACHE - Once the table is loaded, use the database's "RENAME" table command to rename the staging table ( st_xxx ) to the materialized table ( mv_xxx ). Here is the syntax to do this with MySQL:
ALTER TABLE ST_UpdateProduct RENAME MV_UpdateProductThe reason you need to run the "rename" command is that the staging table can be used for loading the data (except for the very first time you use it). Meanwhile, materialized table will serve the user queries. Once the staging is loaded, rename will switch the identity of staged with the materialized such that any future queries will be against newly loaded contents. You can keep repeating this cycle in regular intervals and never serve empty results or wait for results to load. To populate the results via an ETL tool, you can do so too in this step by disregarding the above SQL command.Note
You can script this entire process so that it runs at a regular interval. This example code shows you how to script it if you are using the MySQL database. (Make sure you provide the MySQL jdbc driver in the AdminShell classpath before running the script):// connect to mysql first mysql = Sql.newInstance("jdbc:mysql://host_name:port/dbname", "username","password", "com.mysql.jdbc.Driver") mysql.execute("TRUNCATE TABLE ST_UpdateProducts"); // use the Teiid connection and load the staging table sql=connect(${url}, ${user}, ${password}); sql.execute("INSERT INTO mv_view.st_UpdateProduct SELECT * FROM Portfolio.UpdateProduct OPTION NOCACHE"); sql.close(); // issue the rename command, so that materialization takes into effect mysql.execute("ALTER TABLE ST_UpdateProduct RENAME MV_UpdateProduct"); mysql.close(); // create any indexes you need toAdd the script to your cron tab or Windows Scheduler and set it to run at a regular interval to keep your data fresh.
3.4. Code Table Caching
3.4.1. Code Table Caching
lookup('ISOCountryCodes', 'CountryCode', 'CountryName', 'United States')
- The use of the lookup function automatically performs caching; there is no option to use the lookup function and not perform caching.
- No mechanism is provided to refresh code tables
- Only a single key/return column is cached - values will not be session/user specific.
SELECT (SELECT CountryCode From MatISOCountryCodes WHERE CountryName = tbl.CountryName) as cc FROM tbl
- More control of the possible return columns. Code tables will create a materialized view for each key/value pair. If there are multiple return columns it would be better to have a single materialized view.
- Proper materialized views have built-in system procedure/table support.
- More control via the cache hint.
- The ability to use OPTION NOCACHE.
- There is almost no performance difference.
3.4.2. Create a Materialized View for Code Table Caching
Procedure 3.4. Create a Materialized View for Code Table Caching
- Create a view selecting the appropriate columns from the desired table. In general, this view may have an arbitrarily complicated transformation query.
- Designate the appropriate column(s) as the primary key. Additional indexes can be added if needed.
- Set the materialized property to true.
- Add a cache hint to the transformation query. To mimic the behavior of the implicit internal materialized view created by the lookup function, use the Hints and Options /*+ cache(pref_mem) */ to indicate that the table data pages should prefer to remain in memory.
Just as with the lookup function, the materialized view table will be created on first use and reused subsequently.
3.5. Programmatic Control
dataModification (which affects result set caching) or updateMatViewRow (which affects internal materialization) to alert the Teiid engine that the underlying source data has been modified. These operations, which work cluster wide will invalidate the cache entries appropriately and reload the new cache contents.
Note
EventDistributor interface in their own code that is deployed in the same JBoss EAP virtual machine using a Pojo/MDB/Session Bean:
public class ChanageDataCapture {
public void invalidate() {
InitialContext ic = new InitialContext();
EventDistributor ed = ((EventDistributorFactory)ic.lookup("teiid/event-distributor-factory")).getEventDistributor();
// this below line indicates that Customer table in the "model-name" schema has been changed.
// this result in cache reload.
ed.dataModification("vdb-name", "version", "model-name", "Customer");
}
}
Important
Chapter 4. Result Set Caching
4.1. User Query Cache
Properties info = new Properties();
...
info.setProperty("ResultSetCacheMode", "true");
Connection conn = DriverManager.getConnection(url, info);
Note
...
PreparedStatement ps = connection.prepareStatement("/*+ cache */ select col from t where col2 = ?");
ps.setInt(1, 5);
ps.execute();
...
/*+ cache(pref_mem ttl:60000) */ select col from t
Important
4.2. Procedure Result Caching
/*+ cache */
BEGIN
...
END
4.3. Cache Configuration
Important
4.4. Extension Metadata
vdb.xml:
<vdb name="vdbname" version="1">
<model name="Customers">
<property name="teiid_rel:data-ttl" value="0"/>
...</para>
4.5. Cache Administration
connectAsAdmin()
clearCache("QUERY_SERVICE_RESULT_SET_CACHE")
...
4.6. Caching Limitations
- XML, BLOB, CLOB, and OBJECT type cannot be used as part of the cache key for prepared statement of procedure cache keys.
- The exact SQL string, including the cache hint if present, must match the cached entry for the results to be reused. This allows cache usage to skip parsing and resolving for faster responses.
- Result set caching is transactional by default using the NON_XA transaction mode. To use full XA support, change the configuration to use NON_DURABLE_XA.
- Clearing the results cache clears all cache entries for all VDBs.
4.7. Translator Result Caching
4.8. Cache Hints and Options
- Indicate that a user query is eligible for result set caching and set the cache entry memory preference, time to live and so forth.
- Set the materialized view memory preference, time to live, or updatablity.
- Indicate that a virtual procedure should be cachable and set the cache entry memory preference, time to live and so on
/*+ cache[([pref_mem] [ttl:n] [updatable])] [scope:(session|user|vdb)] */ sql ... - The cache hint should appear at the beginning of the SQL. It will not have any affect on INSERT/UPDATE/DELETE statements or INSTEAD OF TRIGGERS.
- pref_mem- if present indicates that the cached results should prefer to remain in memory. The results may still be paged out based upon memory pressure.
Important
Care should be taken to not over use the pref_mem option. The memory preference is implemented with Java soft references. While soft references are effective at preventing out of memory conditions. Too much memory held by soft references can limit the effective working memory. Consult your JVM options for clearing soft references if you need to tune their behavior. - ttl:n- if present n indicates the time to live value in milliseconds. The default value for result set caching is the default expiration for the corresponding Infinispan cache. There is no default time to live for materialized views.
- updatable- if present indicates that the cached results can be updated. This defaults to false for materialized views and to true for result set cache entries.
- scope- There are three different cache scopes: session - cached only for current session, user - cached for any session by the current user, vdb - cached for any user connected to the same vdb. For cached queries the presense of the scope overrides the computed scope. Materialized views on the other hand default to the vdb scope. For materialized views explicitly setting the session or user scopes will result in a non-replicated session scoped materialized view.
Note
SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE
SELECT * from vg1, vg2, vg3 WHERE … OPTION NOCACHE vg1, vg3
Appendix A. Revision History
| Revision History | |||
|---|---|---|---|
| Revision 6.2.0-24 | Thu Dec 10 2015 | ||
| |||
