#1238 - Refactor MetaInfoManager - collect query plan stats, fix collection of stats on UpdateQuery

This commit is contained in:
Rob Bygrave
2018-01-19 01:07:37 +13:00
parent b9ae76d465
commit 07cdf64ece
27 changed files with 355 additions and 108 deletions
@@ -1,5 +1,6 @@
package io.ebeaninternal.server.query;
import io.ebean.ProfileLocation;
import io.ebean.bean.ObjectGraphNode;
import io.ebean.meta.MetaQueryPlanOriginCount;
import io.ebean.meta.MetaQueryPlanStatistic;
@@ -43,6 +44,13 @@ public final class CQueryPlanStats {
this.origins = !collectQueryOrigins ? null : new ConcurrentHashMap<>();
}
/**
* Return true if there are no statistics collected since the last reset.
*/
public boolean isEmpty() {
return count.sum() == 0;
}
/**
* Add a query execution to the statistics.
*/
@@ -188,8 +196,9 @@ public final class CQueryPlanStats {
@Override
public String toString() {
return queryPlan + " count:" + count + " time:" + totalTime + " maxTime:" + maxTime + " beans:" + totalBeans
+ " start:" + startTime + " lastQuery:" + lastQueryTime + " origins:" + origins;
ProfileLocation profileLocation = queryPlan.getProfileLocation();
String loc = (profileLocation == null) ? "" : profileLocation.shortDescription();
return "location:" + loc + " count:" + count + " time:" + totalTime + " maxTime:" + maxTime + " beans:" + totalBeans + " sql:" + getSql();
}
@Override
@@ -197,6 +206,11 @@ public final class CQueryPlanStats {
return queryPlan.getBeanType();
}
@Override
public ProfileLocation getProfileLocation() {
return queryPlan.getProfileLocation();
}
@Override
public long getExecutionCount() {
return count;