You can achieve better performance in an application that uses SQL repositories by preloading caches. You can configure the SQL repository to save and restore caches automatically. It is generally good practice to put cache-loading tags in a separate XML file with the same name as the repository definition file, and rely on XML file combination to invoke the queries. For more about XML file combination, see the Nucleus: Organizing JavaBean Components chapter of the ATG Platform Programming Guide

If you preload caches, the loading strategy of the preloaded items on startup should be set to eager (the default). Alternatively, you might optimize performance by lazy loading repository items. For more information, see Enabling Lazy Loading later in this chapter.

Note: Performance improvement by preloading caches slows application startup.

You can specify to load certain items into repository caches on application startup in several ways:

Load specific repository items

A repository definition file can include a <load-items> tag to specify one or more repository items to cache on application startup. The tag specifies the items to cache through a comma-delimited list of repository IDs.

For example, the following <load-items> tag specifies to load four items of the products item type that match the listed repository IDs:

<load-items item-descriptor="product">
   prod10001,prod100001,prod100002,prod100003
</load-items>

The <load-items> tag can restrict the cached data to specific properties through the properties attribute. The previous example can be modified to cache only the data of properties displayName and description, as follows:

<load-items item-descriptor="product" properties="displayName,description">
   prod10001,prod100001,prod100002,prod100003
</load-items>
Load queried items

A repository definition file can include <query-items> tags in order to cache query results on application startup. For example:

<query-items item-descriptor="users">ALL</query-items>

The <query-items>tag can also set the quiet attribute to true, to suppress log messages that the query otherwise generates:

<query-items item-descriptor="product" quiet="true">ALL</query-items>

You can set the id-only attribute to true or false:

For example:

<query-items item-descriptor="product" id-only="true">ALL</query-items>

For more information, see the Querying Items section in the Developing and Testing an SQL Repository chapter.

Load from a dump log

You can use the Admin UI to dump the contents of a repository’s item cache at runtime, by executing the <dump-caches<dump-caches> tag in the Admin UI utility Run XML Operation Tags on the Repository. If the tag’s dump-type attribute is set to queries, the tag logs a <load-items<load-items> tag that can be used to reload all the items that were in the cache at the time of the dump. For example:

<dump-caches item-descriptors="product" dump-type="queries"/>

This tag might yield the following log:

*** begin pre-cache XML output

<load-items item-descriptor="product">
   prod100003,prod100002,prod100001,prod10001
/load-items>

*** end pre-cache XML output