Avoid code that incidentally queries the database
As a performance best practice, Guidewire recommends that you avoid object property access or method calls that potentially query the relational database.
Accessing entity arrays does not incidentally query the database
The following sample Gosu code accesses an
array of Vehicle instances
as entity array.
policyLine.Vehicles // Accessing an entity array does not query the database.Accessing the entity array does not incidentally query the relational database. The application database caches them whenever it loads a parent entity from the relational database.
Accessing finder arrays incidentally queries the database
The following sample Gosu code accesses an
array of Policy entities
by using a Finder method
on a Policy instance.
policy.Finder.findLocalPoliciesForAccount(account) // Accessing a finder array queries the database.Calling a Finder method does incidentally query the relational database. However, the application database does not cache finder arrays. Only your code keeps the array in memory.
To avoid repeated, redundant calls that incidentally query the database, Guidewire recommends as a best practice that you cache the results once in a local array variable. Then, pass the local array variable to lower level routines to operate on the same results. This design approach is an example of pulling up.
See also
