Oracle Database Cache Concepts and Administration Guide
Release 1.0.2.1

Part Number A88706-01

Library

Service

Contents

Index

Go to previous page Go to next page

2
Setting Up Oracle Database Cache

To set up Oracle Database Cache, you use Cache Manager, a component of Oracle DBA Studio. Cache Manager is an easy-to-use, Java-based interface that helps you to set up the middle-tier caches, specify the data and PL/SQL objects (packages, procedures, and functions) to be cached in each, and specify the synchronization policy of each table in each cache.


Note:

Oracle Database Cache provides a cache management API, which is loaded into the cache during installation. The API provides PL/SQL procedures and functions that allow you to use a utility such as SQL*Plus to perform many of the tasks you perform with Cache Manager. For more information about the API, see Chapter 6.

Oracle Database Cache also provides views that allow you to use SQL to access information, such as a list of cached objects, from the cache. For more information about the views, see Appendix A


Setting Up Oracle Database Cache: General Steps

To set up Oracle Database Cache, you take the following general steps:

  1. Design your Oracle Database Cache environment, deciding which data to cache. See "Designing Your Oracle Database Cache Environment".

  2. Install Oracle Database Cache on the middle-tier nodes, such as Web or application servers, on which you want to cache data. Then, install the management interface on a client node. See "Installing Oracle Database Cache".

  3. Invoke Oracle DBA Studio. See "Invoking Oracle DBA Studio".

  4. Set up the caches on the middle-tier nodes by specifying the data to be cached in each middle-tier cache and by specifying other characteristics of the cache, such as the synchronization policies, memory allocation, and disk allocation. In addition, you can specify the PL/SQL packages, procedures, and functions to be cached. (You should cache only read-only PL/SQL objects.) See "Setting Up the Caches".

  5. Enable routing of queries, including PL/SQL subprograms and anonymous blocks, to the cache. See "Enabling Routing to the Cache".

  6. Configure your application environment to use caching. See "Configuring Your Application Environment".

Designing Your Oracle Database Cache Environment

Before you begin setting up Oracle Database Cache, take time to design your Oracle Database Cache environment. In doing so, you gather the following information:

When you have answered these questions, you will have the necessary information to set up and deploy Oracle Database Cache.

Determining the Data to Be Cached

The first step in designing your Oracle Database Cache environment is determining which data you should cache. To that end, answer the following questions:

Now you have identified the data to be cached. Oracle Database Cache caches and manages data in entities called data sets. A data set is any collection of data items that can be expressed using a SQL statement. A data set can be a table, any subset of a table, or data from more than one table.


Note:

For this release of Oracle Database Cache, you must cache entire tables; you cannot cache just the parts of tables that satisfy the query. As a result, a data set must be an entire database table.  


As an example, after answering the preceding questions, you determine that your company Web site, GreatStore.com, has several frequently requested queries:

In this example, you decide that you need to cache the BOOKS_ORDERED and NYT_BEST tables from the BOOKS database and the SOFT_SPEC table from the SOFTWARE database. Each table to be cached is a data set.

Deciding Where to Cache the Data

Using Oracle Database Cache, you cache the data in a cache on a middle-tier node.

In most cases, a company may have several middle-tier servers, such as Web servers or application servers, that handle all requests. If the data is stored in only one origin database, you can cache the same data on all middle-tier servers. That is, you can have identical caches on all nodes.

In some cases, a company may have several middle-tier servers, but it routes different types of requests to different Web servers. For example, in an online news publishing company, Web servers A and B are responsible for requests for the weather information; Web servers C and D are responsible for requests for sports information. In this situation, you cache different data on Web servers A and B than on C and D.


Note:

For this release, data from only one origin database can be cached in any particular cache.  


Using the GreatStore.com scenario described in the previous section, you must cache your data on at least two different middle-tier nodes because your data resides in two separate origin databases. You decide to cache data about books in the caches on several middle-tier nodes. You cache identical data sets in these caches. Then, you decide to cache data about computer software in the caches located on several other middle-tier nodes. You cache identical data about computer software in these caches.

Deciding Synchronization Policies

When you synchronize data, you make the data in the cache consistent with the data in the origin database by refreshing the cache with the current data from the origin database. The synchronization policy establishes how and how often the data in the cache is refreshed from the origin database. You can specify different synchronization policies for each data set.

You can choose incremental or complete synchronization:

If there is a large amount of data in the data set, a complete synchronization can take considerably more time than an incremental synchronization. However, if a large percentage of data in a data set changes, a complete synchronization is more efficient than an incremental synchronization.

For either of these types of synchronization, you can schedule synchronization at specified intervals or you can use Cache Manager to synchronize the data at any point in time.

When you can predict how often the data needs to be synchronized, schedule the synchronization to occur at specified intervals.

For example, your Web site may list the 100 books that are the top sellers on your Web site. The results of such a query change quite frequently, so you decide to synchronize the data once each hour.

In setting the interval, consider the frequency of updates to the data in the origin database. In addition, consider your environment's tolerance for stale data. If there is low tolerance, synchronize often; if there is high tolerance, synchronize less often.

If you cannot predict how often the data needs to be synchronized, or if you want to synchronize the data at a time other than the scheduled time, you can use Cache Manager to synchronize the data.

For example, a Web site for ordering sporting goods contains a catalog of items. New items are added to the catalog at irregular intervals, making it difficult to predict a schedule for synchronization. In this case, you can synchronize the data when the changes in data in the origin database necessitate it.

When you plan the synchronization of your data, consider carefully how you want the data to be refreshed throughout your Oracle Database Cache environment. You may want to schedule synchronization at a time of day when connectivity is guaranteed or when communication costs are lowest. If your caches or origin database experiences a high volume of transactions during the business day, consider scheduling the synchronization during off-peak hours. Furthermore, you might want to stagger the synchronization to distribute the load on the origin database over time, rather than scheduling the synchronization of many caches at the same time.

If the synchronization intervals are very short or the data changes rapidly, you may see an effect on performance because of the processing required to keep the middle-tier cache synchronized with the origin database.

If the synchronization takes longer than the interval specified, the table will be continually refreshed. For example, if you specify an interval of 5 minutes, but the synchronization takes 6 minutes to complete, the next scheduled synchronization will start immediately after the first one completes.

If two or more requests to synchronize a particular table are issued simultaneously, one of the requests will succeed. The other requests will fail with an error.

Note that while you can easily change the synchronization policy from scheduled to not scheduled, changing the policy from Complete to Incremental or Incremental to Complete consumes more resources and may take considerable time if the table is very large.

Deciding Which PL/SQL Objects to Cache

You can cache PL/SQL objects (packages, procedures, and functions). Consider the following when deciding which, if any, PL/SQL objects to cache:

Installing Oracle Database Cache

You install Oracle Database Cache on all nodes in the middle tier where you want to cache data. When you install Oracle Database Cache, you specify which Oracle database you want to use as the origin database. The installation procedure creates a cache on the Oracle Database Cache node and prepares the origin database for use by Oracle Database Cache.

In addition, you install Oracle Enterprise Manager, including DBA Studio. Cache Manager is a component of DBA Studio.

For more information about how to install Oracle Database Cache, see the installation guide.

Invoking Oracle DBA Studio

Oracle DBA Studio is a Java-based interface that you use to manage your Oracle environment. Cache Manager, a component of DBA Studio, provides the interface to manage your Oracle Database Cache environment and provides wizards that take you through the process of setting up and deploying your Oracle Database Cache environment.

You can start DBA Studio through the Oracle Enterprise Manager console or as a standalone application.

To invoke the Oracle Enterprise Manager console on UNIX systems, such as Sun Solaris, enter the following command:

oemapp console

To invoke the Oracle Enterprise Manager console on Windows NT systems, from the Windows NT Start menu, select Programs -> Oracle_home_name -> Oracle Enterprise Manager -> Console.

Then, from the console, select Tools -> Database Applications -> DBA Studio or select the Database Applications icon from the toolbar and then select the DBA Studio icon.

Note that Oracle Database Cache does not support the jobs and events subsystem or discovery of cache nodes.

To start DBA Studio as a standalone application on UNIX systems, enter the following command:

oemapp dbastudio

To start DBA Studio as a standalone application on Windows NT systems, from the Windows NT Start menu, select Programs -> Oracle_home_name -> DBA Management Pack -> DBA Studio.

When you invoke DBA Studio, it displays the Oracle Enterprise Manager Login dialog box:


Text description of oemlogon.gif follows.
Text description of the illustration oemlogon.gif

Select Launch DBA Studio standalone. Click OK.

When you log in successfully, DBA Studio is displayed:


Text description of dba_studio.gif follows.
Text description of the illustration dba_studio.gif

Before you can connect to an origin database, you must add it to the list in the Navigator tree. Take the following steps:

  1. Choose File -> Add Database to Tree.

  2. In the Add Databases to Tree dialog box, select Add a database manually.


    Text description of dbadd.gif follows.
    Text description of the illustration dbadd.gif

  3. In the dialog box, enter the following information:

    • For Hostname, enter the name of a node that contains the origin database.

    • For Port Number, enter the number of the port of the origin database. By default, the port number is 1521.

    • For SID, enter the Oracle system identifier.

    • When you enter the Hostname and SID, DBA Studio completes the Net Service Name.

    Alternatively, if the origin database is listed in the local tnsnames.ora file, it is displayed in the Service Name list. In this case, you can select Add selected databases from your local tnsnames.ora file. Then, select the database service name.

  4. Click OK.

DBA Studio lists the origin database in the Navigator tree. When you log in to DBA Studio in the future, the database will be listed in the tree.

To connect to the database, take the following steps:

  1. Select the origin database from the Navigator tree and click the Connect icon. DBA Studio displays the Database Connect Information dialog box.


    Text description of dblogin.gif follows.
    Text description of the illustration dblogin.gif

  2. Enter the following information:

    • For Username, enter the name of a valid user for the origin database. The user must have DBA privileges, because many of the operations you can perform require this level of privileges.

    • For Password, enter the password for the specified user.

  3. Click Save As Local Preferred Credentials. This saves the connect information and allows you to access the database in the future without specifying the connect information.

  4. Click OK.

DBA Studio authenticates the user, checking that the user is a valid user with the requisite privileges in the origin database. When you log in successfully, DBA Studio expands the database in the Navigator tree.

To manage your Oracle Database Cache environment, select the Caches folder from the Navigator tree. DBA Studio displays information about Cache Manager and a button to view the Oracle Database Cache Quick Tour.

Expand Caches to see the caches associated with the origin database. Oracle Database Cache attempts to attach to the associated caches. The icons for each cache show the state of the cache.


Text description of dbtree.gif follows.
Text description of the illustration dbtree.gif

Now, select a cache from the Navigator tree to see information about that cache:


Text description of console_annot.gif follows.
Text description of the illustration console_annot.gif

The preceding illustration points out some of the features of DBA Studio and Cache Manager:

For detailed information about each property page, dialog box, and wizard, see the online Help.

Setting Up the Caches

The caches were created when you installed Oracle Database Cache. Now, you use Cache Manager to specify which data and PL/SQL objects are cached in which middle-tier caches and the synchronization policy for each table in the caches.


Note:

The tables are stored in the cache using the same character set as specified as the character set of the origin database.  


Cache Manager provides the Add Wizard, which lets you set up and populate one or more caches at the same time. With the wizard, you can add tables and PL/SQL objects to one or more caches and specify the synchronization policy for each table.

When you are setting up your Oracle Database Cache environment for the first time, consider using the Add Wizard to set up one cache. Then, verify and test that you set up the cache in the best way for your environment. When you are satisfied with the setup, you can easily copy it to other caches. The following sections describe how to use this method.

If you accepted the default value for the amount of disk space allocated to the cache, you should consider increasing the amount of disk space before you add tables to the caches. The following section describes how to add disk space.

Increasing the Disk Space Allocated to a Cache

If you accepted the default value for the amount of disk space allocated to the cache and you plan to cache a large amount of data, you may need to increase the disk space allocated to the cache.

You can increase the amount of disk space available for a cache in the following ways:

Note that performance improves if you allocate the disk space in large amounts. That is, performance is better if you allocate disk space using a few large files rather than many smaller files.

To modify the amount of disk space allocated to a cache, take the following steps to invoke the Change Allocated Disk Space dialog box:

  1. From the Navigator tree, select the cache.

  2. From the Cached Tables tab, click Change.

  3. Cache Manager displays the Change Allocated Disk Space dialog box, which shows the files that hold the allocated disk space for the cache.

To increase the amount of disk space allocated to a cache by adding a new file, take the following steps:

  1. In the Change Allocated Disk Space dialog box, enter the following information in the last row:

    • For File Name, enter the name for the file.

    • For File Directory, enter the full specification for an existing directory on the middle-tier node that will hold the file. Note that the naming convention must follow the rules for the middle-tier node.

    • For Size, enter the size, in megabytes, for the file.


      Text description of incr_disk1.gif follows.
      Text description of the illustration incr_disk1.gif

  2. Click OK. Cache Manager updates the Disk Space Allocated field on the Cache Tables page.

  3. Click Apply. Cache Manager adds the new file to the cache.

To increase the amount of disk space allocated to a cache by increasing the size of an existing file, take the following steps:

  1. In the Change Allocated Disk Space dialog box, enter the new amount, in megabytes, in the Size field for a particular file.

  2. Click OK. Cache Manager updates the Disk Space Allocated field on the Cache Tables page.

  3. Click Apply. Cache Manager adds the additional disk space to the cache.

Using the Add Wizard to Set Up Caches

To invoke the Add Wizard, select the Caches folder from the Navigator tree and choose Object -> Add Objects to Caches. Then, take the following steps:

  1. The wizard displays the Welcome page. Click Next.

  2. The Select Caches page shows the caches to which you can add objects (tables and PL/SQL objects.) This page displays all caches that are configured for the current origin database and that are running or paused.

    To cache objects in particular caches, select the caches in which you want to cache objects and click the right arrow (>) to move them from the Available Caches list to the Selected Caches list. To remove caches in which you do not want to cache objects from the Selected Caches list, select the caches and click the left arrow (<).


    Text description of addwiz_cache.gif follows.
    Text description of the illustration addwiz_cache.gif
  3. Click Next.

  4. The Select Tables page lets you select which tables to cache in the selected caches. In the Available Tables list, expand the schemas. The list displays all tables that can be added to the caches you selected. If a table is already cached in all selected caches, the table will not be displayed in either list.

    To check the dependencies of a table, from the Available Tables list, select the table and click the Show Dependencies icon.

    From the Available Tables list, select the tables that you want to include in the caches. Click the right arrow (>) to move the tables to the Selected Tables list.


    Text description of addwiz_table.gif follows.
    Text description of the illustration addwiz_table.gif
  5. When you have selected the tables, click Next.

  6. On the Synchronization Policy Overview page, you indicate whether you want to use the same synchronization policy for all tables in the caches or to specify different policies for some tables.

    To specify the same synchronization policy for all tables, select Yes, use the same policy for every table. If any caches contain any of the tables you selected on the previous page, the wizard will not add those particular tables to those caches and will not change the synchronization policies of those tables on those caches.

    To specify different synchronization policies for one or more tables, select No, let me set a different policy for some tables.


    Text description of addwiz_sync.gif follows.
    Text description of the illustration addwiz_sync.gif
  7. Click Next.

  8. On the Synchronization Policy Method page, you specify the synchronization method for all or most of the tables you have selected. You can select one of the following methods:

    • Incremental: Synchronize the data by refreshing only the data that has changed since the table was cached or since it was last synchronized.

    • Complete: Synchronize the data by completely refreshing the table. When you select this method, Oracle Database Cache deletes all data in the table and replaces it with the current data from the origin database.


      Text description of addwiz_sync1.gif follows.
      Text description of the illustration addwiz_sync1.gif

    See "Deciding Synchronization Policies" for more information about synchronization policies.

  9. Click Next.

  10. On the Synchronization Policy Schedule page, you specify when you want the synchronization to occur for most or all of the tables.


    Text description of addwiz_sync2.gif follows.
    Text description of the illustration addwiz_sync2.gif

    You can choose one of the following:

    • Yes, schedule the synchronization to: The synchronization occurs at specified intervals. Use this option when you can predict how often the data needs to be synchronized.

      If you choose this option, you specify the start time and the interval between synchronizations:

      • In the Start at field, enter the date and time to start the synchronization. You can select each field in the date and time string and use the arrow to select the correct time. Note that the time reflects the time zone defined for the middle-tier node.

      • In the Every field, enter a number for the interval in the first box and select a unit, such as minutes, hours, days, or weeks, in the second box.

    • No, do not schedule automatic synchronization: The synchronization occurs only when you initiate the action. Use this option when you cannot predict how often the data needs to be synchronized.

  11. Click Next.

  12. If you selected Yes, use the same policy for every table in step 6, skip to step 14.

    If you selected No, let me set a different policy for some tables, Cache Manager displays the next page, Synchronization Policy for Tables.


    Text description of addwiz_synctab.gif follows.
    Text description of the illustration addwiz_synctab.gif

    For those tables for which you want a different synchronization policy, take these steps:

    1. From the Synchronization Policy column, select the type of synchronization.

    2. If you select Incremental, Scheduled, or Complete, Scheduled, enter the following information:

      • From the Synchronization Start Time column, select the date and time for the synchronization to begin.

      • From the Synchronization Interval column, enter a number for the interval between synchronizations.

      • From the Synchronization Unit column, select a unit of time for the interval, such as minutes, hours, days, or weeks.

  13. Click Next.

  14. The Select PL/SQL Objects page lets you select which PL/SQL Objects to cache in the selected caches. In the Available PL/SQL Objects list, expand the schemas, then expand the folders for procedures, functions, or packages. The list displays all PL/SQL objects that can be added to the caches you selected. If a PL/SQL object is cached in all selected caches, the PL/SQL object will not be displayed in either list.

    To check the dependencies of a PL/SQL object, from the Available PL/SQL Objects list, select the table and click the Show Dependencies icon.

    From the Available PL/SQL Objects list, select the PL/SQL objects that you want to include in the caches. Click the right arrow (>) to move the objects to the Selected PL/SQL Objects list.


    Text description of addwiz_plsql.gif follows.
    Text description of the illustration addwiz_plsql.gif
  15. When you have selected the PL/SQL objects, click Next.

  16. The wizard displays the Summary page. Click Finish.

Oracle Database Cache adds the tables, their data and their dependent objects, and the PL/SQL objects to the caches. The wizard displays a progress box that shows each operation as it completes. If an operation results in an error, the wizard displays an error in the progress box and displays the warning when it completes all operations.

Verifying Your Cache Setup

To verify that you set up your cache correctly, select the cache from the Navigator tree. Cache Manager displays the property sheet for the cache. Then, take the following steps:

  1. Select the Cached Tables tab and check that all tables that you want cached are listed. See "Modifying Which Data Is Cached" for information on adding or removing tables.


    Text description of incr_mem.gif follows.
    Text description of the illustration incr_mem.gif

  2. On the Cached Tables page, check the synchronization policy and intervals for each table. To change the synchronization policy for a table, click in the Synchronization Policy column and select an option.

    If you selected Incremental, Scheduled, or Complete, Scheduled, select a Synchronization Start Time. Then, enter a Synchronization Interval and select a Synchronization Unit, such as minutes, hours, days, or weeks.

  3. On the Cached Tables page, check Memory Allocated, which indicates the amount of memory allocated to the cache. To change the amount, enter the new amount in the Memory Allocated box.


    Note:

    The change to memory allocation will not take effect until the next time the cache is started. 


  4. On the Cached Tables page, check Disk Space Allocated, which indicates the amount of disk space allocated to the cache. To change the disk space allocated, click Change. Cache Manager displays the Change Allocated Disk Space dialog box. You can increase or decrease the size of a particular file or add a new file.

    To increase the disk space by increasing the size of a particular file, enter the increased size in the Size column.


    Text description of incr_disk.gif follows.
    Text description of the illustration incr_disk.gif

    "Modifying the Disk Space Allocated to a Cache" provides more information about increasing or decreasing the disk space allocated.

  5. Click OK.

  6. On the Cached PL/SQL page, check that the correct PL/SQL objects are cached. To check the dependencies of an object, select the object and click Show Dependencies.

  7. If you made any changes, click Apply.

If the cache is set up correctly, you can enable caching and test the cache.

Enabling Routing to the Cache

To enable routing of queries, including PL/SQL subprograms (procedures and functions) and anonymous blocks, to the middle-tier cache, take the following steps:

  1. Select the cache from the Navigator tree. Cache Manager displays the property sheet of the cache.

  2. On the General page, click Running.

  3. Click Apply.

Oracle Database Cache starts the middle-tier cache and enables routing of queries, including PL/SQL subprograms and anonymous blocks, to the cache.

You can disable the routing of PL/SQL subprograms and anonymous blocks by using the DBMS_ICACHE.SET_FLAG procedure. See "SET_FLAG Procedure" for more information.

Now you can test the cache to see that you cached the appropriate tables and that you specified appropriate amounts of disk and memory. For information about monitoring caches, see Chapter 3.

If the cache is set up correctly, you can copy the setup to other middle-tier caches.

Copying Cached Objects to Other Caches

If you have set up one cache and want to duplicate those cache settings to other nodes, you can easily do so using the Copy Cached Objects dialog box:

  1. In the Navigator tree, select the cache that you want to duplicate. Right-click and choose Copy Cached Objects.

  2. In the Copy Cached Objects dialog box, from the Available Caches list, select the caches to which you want to copy the setup and click the right arrow (>) to move the caches to the Selected Caches list.


    Text description of copycache.gif follows.
    Text description of the illustration copycache.gif

  3. Click OK.

Repeat the steps outlined in "Verifying Your Cache Setup" to verify that these caches are set up correctly.

Configuring Your Application Environment

To configure your application environment to use Oracle Database Cache, you must set the environment variable ORA_OCI_CACHE and you must ensure that your applications are using the Oracle home in which Oracle Database Cache is installed.

You set the environment variable ORA_OCI_CACHE to the value "1" in the environment from which your application is invoked. All applications invoked from this environment take advantage of Oracle Database Cache.

For example, on UNIX, you use a shell environment variable; on Windows NT, you use an environment variable.


Note:

To use Oracle Database Cache, you must run your application from a node on which Oracle Database Cache is installed.  


If ORA_OCI_CACHE is not set, applications will not use Oracle Database Cache. (For this release, if you set the environment variable to a value other than "1", caching will be enabled, although only the value "1" will be supported in future releases.)

See "Controlling Which Applications Use Oracle Database Cache" if you use applications that directly call OCI functions and you want to exercise greater control over which applications use Oracle Database Cache.

You must also make sure that your applications are using the Oracle home in which Oracle Database Cache is installed, including OCI libraries from that Oracle home. For example, on UNIX, set the value of the environment variable ORACLE_HOME to the Oracle home for Oracle Database Cache. Set the value of the environment variable LD_LIBRARY_PATH so that the Oracle Database Cache library directory ($ORACLE_HOME/lib) precedes other Oracle library directories.

On Windows NT, from the Start menu, select Oracle for Windows NT -> Oracle Home Selector. Then, select the Oracle home in which you installed Oracle Database Cache. Set the value of the environment variable PATH so that the Oracle Database Cache library directory (ORACLE_HOME\lib) precedes other Oracle library directories.

For more information about using the Oracle home and libraries for Oracle Database Cache, see the installation guide.


Go to previous page Go to next page
Oracle
Copyright © 2001 Oracle Corporation.

All Rights Reserved.

Library

Service

Contents

Index