Description
We could collect last 1000 (maybe configurable) sql statements with per statement statistics: count, min time, max time, avg time,....
May be execution plan (explain) ?
-------------------
Proposed API changes:
So, I introduced interface org.apache.ignite.cache.query.QueryDetailsMetrics with metrics:
/** * Query metrics aggregated by query type and its textual representation. */ public interface QueryDetailsMetrics { /** * @return Query type. */ public String getQueryType(); /** * @return Textual representation of query. */ public String getQuery(); /** * @return Cache where query was executed. */ public String getCache(); /** * Gets total number execution of query. * * @return Number of executions. */ public int getExecutions(); /** * Gets number of completed execution of query. * * @return Number of completed executions. */ public int getCompletions(); /** * Gets number of times a query execution failed. * * @return Number of times a query execution failed. */ public int getFailures(); /** * Gets minimum execution time of query. * * @return Minimum execution time of query. */ public long getMinimumTime(); /** * Gets maximum execution time of query. * * @return Maximum execution time of query. */ public long getMaximumTime(); /** * Gets average execution time of query. * * @return Average execution time of query. */ public double getAverageTime(); /** * Gets total time of all query executions. * * @return Total time of all query executions. */ public long getTotalTime(); /** * Gets latest query start time. * * @return Latest time query was stared. */ public long getLastStartTime(); }
And added method on org.apache.ignite.IgniteCache:
/** * Gets query metrics details. * * @return Metrics. */ public Collection<? extends QueryDetailsMetrics> queryMetricsHistory();
And also I added new property on org.apache.ignite.configuration.CacheConfiguration:
/** * Gets size of queries metrics history that will be stored in memory for monitoring purposes. * If {@code 0} then history will not be collected. * Note, Larger number may lead to higher memory consumption. * * @return Maximum number of query metrics that will be stored in memory. */ public int getQueryMetricsHistorySize() { return qryMetricsHistSz; } /** * Sets size of queries metrics history that will be stored in memory for monitoring purposes. * * @param qryMetricsHistSz Maximum number of latest queries metrics that will be stored in memory. * @return {@code this} for chaining. */ public CacheConfiguration<K, V> setQueryMetricsHistorySize(int qryMetricsHistSz) { this.qryMetricsHistSz = qryMetricsHistSz; return this; }