13.5.4 Using read-ahead hints
Read-ahead schemes enable applications to minimize the number of database round trips by retrieving a working set of CMP beans for the transaction within one query. Read-ahead involves activating the requested CMP beans and caching the data for their related beans, which ensures that data is present for the beans that are most likely to be needed next by an application.
A read-ahead hint is a canonical representation of the related beans to be read. It is associated with a finder method for the requested bean type, which must be an EJB 2.x-compliant CMP entity bean. Currently, only findByPrimaryKey methods can have read-ahead hints. Only beans related to the requested beans by a container-managed relationship (CMR), either directly or indirectly through other beans, can be read ahead.
To set Read-ahead hints...
1. Open the EJB deployment descriptor editor.
2. Select the Access tab and scroll down to the WebSphere Extensions section.
3. Click the Add button to the right of the Access Intent for Entities 2.x (Method Level) field.
Figure 13-19 Adding a read ahead hint
Figure 13-20 Specifying read-ahead hint
4. Follow the windows in the wizard to select the beans and methods, then click Finish.
While using read-ahead hints can improve performance by minimizing the number of database round trips required to retrieve the data for the related beans, overdoing it can have an adverse effect. For example, using read-ahead hints on long or complex paths can result in a query that is too complex to be useful.