I have added a page to the avaje website so that you can view the query execution statistics and autofetch profiling information. This information is coming from the actual website activity.
http://www.avaje.org/metadata.html
In looking at the query execution statistics:
- there is a column indicating that the query was tuned or not via autofetch.
- the 'orig hash' ... can be used to identify the original un-tuned query with later tuned queries. The 'orig hash' can link together lazy loading queries that result from the original query so you can get a 'total object graph' cost (original query + all related lazy loading queries).
Anyway, there is also a link on that page that goes through to the autofetch profiling information that is being collected. This is the information that is used to tune the queries.
Note: The site uses content caching so the query counts can be relatively low. I'll probably clear the cache a few times to get the execution statistics a bit higher.
In case it is not obvious you can use the query statistics to easily find the most expensive queries in your application.
The query statistics are retrieved via:
List<MetaQueryStatistic> queryStats = Ebean.find(MetaQueryStatistic.class).findList();
In Ebean v1.2 you can use the Ebean.sort() method to sort the returned list like:
Ebean.sort(queryStats,"avgTimeMicros desc, executionCount");
Ultimately you could retrieve and store the query execution statistics periodically if you want to maintain a history of the performance of the application over time.
NB: The query execution statistics have been refactored in Ebean v1.2
Cheers, Rob.