SELECT
from
view V1 would fetch data and calculate the results, returning a single
number. If you cache the result anyone selecting from the view will
receive the result immediately. For example,
CREATE VIEW V1 AS SELECT AVG(B1) FROM A,B,C,D,E where E .C1 < (SELECT AVG(C1) FROM E) AND B.C1 = A.C1 AND C.C1 < B.C1 AND D.C1 * E.C1 > SUM(B.C1)
Only definer's rights
views can be used to cache data.
|
Who
|
Action
|
Privilege on Object
|
---|---|---|
User
|
Create a cache
Create or drop cached
views within a schema
Refresh cached views
within the schema
|
CONNECT on ADMIN DSN
CREATE CACHE on the
VS
ALTER CACHE on the VS
|
CS_Owner – owns
all cache tables in its schema, and this identity is used for executing
the view and saving the cached data.
|
Assigned to CS object
Execute, Save cached
data
Must have a database
login to the database of the cached tables if the cached location
requires credentials.1
|
CONNECT on Data service
that contains cache tables.
|
VS_Owner – owner
of the schema where the cached view resides.
|
Cache results sets in
the CS for views owned by the VS_Owner.2
|
CREATE TABLESPACE on
CS
|
CREATE CACHE "catalog"."schema"."view"
IN "cache-catalog"."cache-schema"
SET
RESTART=’REFRESH’
when creating the cache.
ALTER CACHE "catalog"."schema"."view"
REFRESH | DISABLE | ENABLE
ALTER CACHE [view_catalog_name.[view_schema_name.]]view_name
DISABLE
ALTER CACHE [view_catalog_name.[view_schema_name.]]view_name
ENABLE
PURGE CACHE
ALTER SERVER {OPTIONS(xset PURGE_CACHE XX)}
where xx
is
the time-out value in minutes.
0
indicates that the cleanup thread wakes whenever a CREATE CACHE
, ALTER
CACHE REFRESH
, DROP CACHE
, or PURGE
CACHE
statement is issued, or when the view is dropped.
Note that this might not clean up all old caches since some cache
views might be in use at the time of cleanup.
CREATE CACHE
includes
an option value of [DEFERRED]
.
DROP CACHE [view_catalog_name.[view_schema_name.]]view_name
[FORCE]