ApacheCon US 2008 Session

Accelerating performance with Views and Dynamic Views

Databases are designed to store vast amounts of data, and allow for relative extraction of any parts of that data. However, when doing nested loops, the database has to open/close/re-read whatever cache statistics it maintains for each sub-query. There is also a per-request overhead. This does not allow the database to do what it does best; optimizing retrieval. Since the nested queries come in separately, the database does not know the access pattern, so has to rebuild it's query plan, reopen tables, open/close any associated locks, etc.

This is not efficient. Discussion will entail being able to recognize such access patterns, and to reduce the number of separate delegator.find calls. As an example, existing code in OfBiz will be modified in the second half of the talk. Sub-components of this talk will be restricting the set of returned fields in the query to the bare minimum required, to handle the calling codes requirements, and to allow for proper chained cache clearing.

Topics Covered: Recognizing nested query access patterns; Converting code to a dynamic or normal view; Reducing the set of returned fields, but still allow the cache system to do it's magic; Making use of org.ofbiz.entity.cache.Cache.put(Object), to save time from having to rebuild complex object graphs.