Class SlowQueryLog
java.lang.Object
com.loomcache.server.query.SlowQueryLog
Logs and analyzes slow queries in a bounded circular buffer.
Provides query pattern analysis and performance statistics for tuning.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA query pattern with statistics.static final recordRecord representing a single slow query log entry.static final recordStatistics about slow queries grouped by normalized SQL pattern. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a SlowQueryLog with default settings (100ms threshold, 1000 entries).SlowQueryLog(long slowQueryThresholdMs, int maxBufferSize) Creates a new SlowQueryLog with configurable threshold and buffer size. -
Method Summary
Modifier and TypeMethodDescriptiongetSlowQueries(int limit) Returns the most recent slow queries (limit).getSlowQueries(long sinceTimestamp) Returns slow queries logged since the given timestamp.Returns statistics about slow queries grouped by normalized SQL pattern.longReturns the current threshold in milliseconds.longReturns the total number of slow queries logged.voidlogQueryIfSlow(String sql, long executionTimeMs, long rowsScanned, long rowsReturned, String clientId, String mapName) Logs a query if its execution time exceeds the threshold.
-
Constructor Details
-
SlowQueryLog
public SlowQueryLog(long slowQueryThresholdMs, int maxBufferSize) Creates a new SlowQueryLog with configurable threshold and buffer size.- Parameters:
slowQueryThresholdMs- threshold in milliseconds to consider a query slow (default 100)maxBufferSize- maximum number of entries to keep (default 1000)
-
SlowQueryLog
public SlowQueryLog()Creates a SlowQueryLog with default settings (100ms threshold, 1000 entries).
-
-
Method Details
-
logQueryIfSlow
public void logQueryIfSlow(String sql, long executionTimeMs, long rowsScanned, long rowsReturned, String clientId, String mapName) Logs a query if its execution time exceeds the threshold.- Parameters:
sql- the SQL query stringexecutionTimeMs- execution time in millisecondsrowsScanned- number of rows scannedrowsReturned- number of rows returnedclientId- client identifiermapName- name of the map queried
-
getSlowQueries
Returns the most recent slow queries (limit).- Parameters:
limit- maximum number of entries to return- Returns:
- list of slow query entries in reverse chronological order
-
getSlowQueries
Returns slow queries logged since the given timestamp.- Parameters:
sinceTimestamp- timestamp in milliseconds- Returns:
- list of matching entries in reverse chronological order
-
getSlowQueryPatterns
Returns statistics about slow queries grouped by normalized SQL pattern.- Returns:
- SlowQueryStats with pattern analysis
-
getTotalSlowQueries
public long getTotalSlowQueries()Returns the total number of slow queries logged. -
getSlowQueryThreshold
public long getSlowQueryThreshold()Returns the current threshold in milliseconds.
-