Differentiate between explicit queries and decomposed queries.
This commit is contained in:
@@ -47,6 +47,9 @@ public class Stats
|
||||
/** The total number of collection queries that were loaded from the database. */
|
||||
public final int uncachedQueries;
|
||||
|
||||
/** The total number of one-phase collection queries that executed. */
|
||||
public final int explicitQueries;
|
||||
|
||||
/** The number of record loads (individual or as part of a collection query) that were
|
||||
* loaded from the cache. */
|
||||
public final long cachedRecords;
|
||||
@@ -69,7 +72,7 @@ public class Stats
|
||||
|
||||
/** Creates a stats instance. */
|
||||
protected Snapshot (int totalOps, long connectionWaitTime,
|
||||
int cachedQueries, int uncachedQueries,
|
||||
int cachedQueries, int uncachedQueries, int explicitQueries,
|
||||
int cachedRecords, int uncachedRecords,
|
||||
Histogram queryHisto, long queryTime,
|
||||
Histogram modifierHisto, long modifierTime)
|
||||
@@ -78,6 +81,7 @@ public class Stats
|
||||
this.connectionWaitTime = connectionWaitTime;
|
||||
this.cachedQueries = cachedQueries;
|
||||
this.uncachedQueries = uncachedQueries;
|
||||
this.explicitQueries = explicitQueries;
|
||||
this.cachedRecords = cachedRecords;
|
||||
this.uncachedRecords = uncachedRecords;
|
||||
this.queryHisto = queryHisto;
|
||||
@@ -90,7 +94,8 @@ public class Stats
|
||||
public synchronized Snapshot getSnapshot ()
|
||||
{
|
||||
return new Snapshot(_totalOps, _connectionWaitTime,
|
||||
_cachedQueries, _uncachedQueries, _cachedRecords, _uncachedRecords,
|
||||
_cachedQueries, _uncachedQueries, _explicitQueries,
|
||||
_cachedRecords, _uncachedRecords,
|
||||
_readHisto.clone(), _readTime, _writeHisto.clone(), _writeTime);
|
||||
}
|
||||
|
||||
@@ -115,11 +120,12 @@ public class Stats
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void noteQuery (int cachedQueries, int uncachedQueries,
|
||||
public synchronized void noteQuery (int cachedQueries, int uncachedQueries, int explicitQueries,
|
||||
int cachedRecords, int uncachedRecords)
|
||||
{
|
||||
_cachedQueries += cachedQueries;
|
||||
_uncachedQueries += uncachedQueries;
|
||||
_explicitQueries += explicitQueries;
|
||||
_cachedRecords += cachedRecords;
|
||||
_uncachedRecords += uncachedRecords;
|
||||
}
|
||||
@@ -133,6 +139,6 @@ public class Stats
|
||||
protected Histogram _writeHisto = new Histogram(0, 500, 20);
|
||||
protected long _writeTime;
|
||||
|
||||
protected int _cachedQueries, _uncachedQueries;
|
||||
protected int _cachedQueries, _uncachedQueries, _explicitQueries;
|
||||
protected int _cachedRecords, _uncachedRecords;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class FindAllKeysQuery<T extends PersistentRecord> extends Query<List<Key
|
||||
// from Query
|
||||
public void updateStats (Stats stats)
|
||||
{
|
||||
stats.noteQuery(0, 1, 0, 0); // one uncached query
|
||||
stats.noteQuery(0, 1, 0, 0, 0); // one uncached query
|
||||
}
|
||||
|
||||
protected boolean _forUpdate;
|
||||
|
||||
@@ -215,18 +215,15 @@ public abstract class FindAllQuery<T extends PersistentRecord> extends Query<Lis
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
result.add(_marsh.createObject(rs));
|
||||
_uncachedRecords++;
|
||||
}
|
||||
} finally {
|
||||
JDBCUtil.close(stmt);
|
||||
}
|
||||
_uncachedQueries++;
|
||||
_explicitQueries++;
|
||||
if (PersistenceContext.CACHE_DEBUG) {
|
||||
log.info("Loaded " + _marsh.getTableName(), "query", _select,
|
||||
"uncached", _uncachedRecords);
|
||||
log.info("Loaded " + _marsh.getTableName(), "query", _select, "rows", result.size());
|
||||
}
|
||||
// TODO: do we want to cache these results?
|
||||
return result;
|
||||
return result; // TODO: do we want to cache these results?
|
||||
}
|
||||
|
||||
protected SelectClause<T> _select;
|
||||
@@ -235,7 +232,8 @@ public abstract class FindAllQuery<T extends PersistentRecord> extends Query<Lis
|
||||
// from Query
|
||||
public void updateStats (Stats stats)
|
||||
{
|
||||
stats.noteQuery(_cachedQueries, _uncachedQueries, _cachedRecords, _uncachedRecords);
|
||||
stats.noteQuery(_cachedQueries, _uncachedQueries, _explicitQueries,
|
||||
_cachedRecords, _uncachedRecords);
|
||||
}
|
||||
|
||||
protected FindAllQuery (PersistenceContext ctx, Class<T> type)
|
||||
@@ -365,5 +363,6 @@ public abstract class FindAllQuery<T extends PersistentRecord> extends Query<Lis
|
||||
|
||||
protected Class<T> _type;
|
||||
protected DepotMarshaller<T> _marsh;
|
||||
protected int _cachedQueries, _uncachedQueries, _cachedRecords, _uncachedRecords;
|
||||
protected int _cachedQueries, _uncachedQueries, _explicitQueries;
|
||||
protected int _cachedRecords, _uncachedRecords;
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ public class FindOneQuery<T extends PersistentRecord> extends Query<T>
|
||||
// from Operation
|
||||
public void updateStats (Stats stats)
|
||||
{
|
||||
stats.noteQuery(0, 0, _cachedRecords, 1-_cachedRecords);
|
||||
stats.noteQuery(0, 0, 0, _cachedRecords, 1-_cachedRecords);
|
||||
}
|
||||
|
||||
protected CacheKey getCacheKey ()
|
||||
|
||||
Reference in New Issue
Block a user