- AutoFetch
AutoFetch
[http://www.cs.utexas.edu/~aibrahim/autofetch/ AutoFetch] is a mechanism for automatically tuning Object Relational Mapping queries.Ali Ibrahim and William Cook at the University of Texas developed the idea of "AutoFetch" including an implementation for [http://sourceforge.net/projects/autofetch Hibernate] and followed later by an implementation in [http://www.avaje.org Ebean ORM] .
Benefits
Improving the modularity of application code
AutoFetch uses the program state (typically the Call Stack) to classify queries.This means that AutoFetch can tune the same query depending on HOW it was called.
For example, a Data Access API such as
findCustomer(int customerId)
can be tuneddifferently depending on the callers of the method.Reducing the development and maintenance burden from Developers
Because AutoFetch automatically gathers the profiling information developers do not need to manuallytry and gather this information and apply performance optimizations to the code.
AutoFetch can monitor the object graph usage so that if the usage changes the tuning of the query canchange to suit. This reduces the code maintenance issues for developers and maintains optimal performanceas usage changes over time.
How it works
AutoFetch collects object graph usage when queries are executed. It collects the 'profile' information which is later usedto automatically tune the query on subsequent executions. The ORM query is tuned by determining andautomatically adding the correct prefetch directives for each query.
This improves the performance of the application by reducing "lazy loading". For ORMs that support partial objects AutoFetch can also tune the query by just including the properties that the application uses rather than all properties.
Future Directions
AutoFetch profiling can also be used to select optimal query strategies such as "array fetching" where object graph use isknown to be uneven (typically weighted to the first object graphs in a list).
This could lead to much more efficient and higher performing object graph traversal than is currently possible with currenttechniques employed by ORM tools.
See also
*
Object-relational mapping Object Relational Mapping
* [http://www.hibernate.org Hibernate]
* [http://www.avaje.org Ebean]
Wikimedia Foundation. 2010.