by Rob 11 May 09:06
Getting query execution statistics

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.

13 May 09:55
by Rob

Added another page that shows the top ten queries (by average execution time and top ten by total aggregate execution time).

http://www.avaje.org/metatopqueries.html


Cheers, Rob.

Create a New Topic

Title:
Body:
 
Introduction User Guide (pdf) Install/Configure Public JavaDoc Whitepapers
General Database Specific Byte Code Deployment Annotations Features
Top Bugs Top Enhancements
woResponse