Package org.hibernate.stat
Interface Statistics
-
- All Known Subinterfaces:
StatisticsImplementor
- All Known Implementing Classes:
StatisticsImpl
public interface Statistics
Exposes statistics collected from all sessions belonging to a particularSessionFactory
.Collection of statistics is enabled if the configuration property "hibernate.generate_statistics" is set to
true
. It may be dynamically enabled or disabled at runtime by callingsetStatisticsEnabled(boolean)
.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_QUERY_STATISTICS_MAX_SIZE
The default value of the configuration property "hibernate.statistics.query_max_size".
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
clear()
Reset all statistics.@Nullable CacheRegionStatistics
getCacheRegionStatistics(String regionName)
Obtain the statistics for either a domain data or query result cache region.long
getCloseStatementCount()
The number of prepared statements that were released.long
getCollectionFetchCount()
The global number of collections fetched.long
getCollectionLoadCount()
The global number of collections loaded.long
getCollectionRecreateCount()
The global number of collections recreatedlong
getCollectionRemoveCount()
The global number of collections removed.String[]
getCollectionRoleNames()
The names of all collection roles.CollectionStatistics
getCollectionStatistics(String role)
Obtain the statistics for the collection with the given role.long
getCollectionUpdateCount()
The global number of collections updated.long
getConnectCount()
The global number of connections requested by sessions.CacheRegionStatistics
getDomainDataRegionStatistics(String regionName)
Obtain the second-level cache statistics for the given cache region.long
getEntityDeleteCount()
The global number of entity deletes.long
getEntityFetchCount()
The global number of entity fetches.long
getEntityInsertCount()
The global number of entity inserts.long
getEntityLoadCount()
The global number of entity loads.String[]
getEntityNames()
The names of all entities.EntityStatistics
getEntityStatistics(String entityName)
Obtain the statistics for the entity with the given name.long
getEntityUpdateCount()
The global number of entity updates.long
getFlushCount()
The global number of flush operations executed, including automatic (either manual or automatic).long
getNaturalIdCacheHitCount()
The global number of cached natural id lookups successfully retrieved from the cache.long
getNaturalIdCacheMissCount()
The global number of cached natural id lookups not found in the cache.long
getNaturalIdCachePutCount()
The global number of cacheable natural id lookups put in cache.long
getNaturalIdQueryExecutionCount()
The global number of natural id queries executed against the database.long
getNaturalIdQueryExecutionMaxTime()
The global maximum query time for natural id queries executed against the database.@Nullable String
getNaturalIdQueryExecutionMaxTimeEntity()
The entity name for the maximum natural id query time.@Nullable String
getNaturalIdQueryExecutionMaxTimeRegion()
The region for the maximum natural id query time.NaturalIdStatistics
getNaturalIdStatistics(String entityName)
Obtain the natural id resolution statistics for the entity type with the given name.long
getOptimisticFailureCount()
The number of HibernateStaleObjectStateException
s or JPAOptimisticLockException
s that have occurred.long
getPrepareStatementCount()
The number of prepared statements that were acquired.String[]
getQueries()
All executed query strings.long
getQueryCacheHitCount()
The global number of cached queries successfully retrieved from the cache.long
getQueryCacheMissCount()
The global number of cached queries notnot found in the cache.long
getQueryCachePutCount()
The global number of cacheable queries put in cache.long
getQueryExecutionCount()
The global number of executed queries.long
getQueryExecutionMaxTime()
The time in milliseconds of the slowest query.@Nullable String
getQueryExecutionMaxTimeQueryString()
The query string for the slowest query.long
getQueryPlanCacheHitCount()
The global number of query plans successfully retrieved from cache.long
getQueryPlanCacheMissCount()
The global number of query plans lookups not found in cache.@Nullable CacheRegionStatistics
getQueryRegionStatistics(String regionName)
Obtain the second-level cache statistics for the given query cache region.QueryStatistics
getQueryStatistics(String queryString)
Obtain the query statistics for the given query string.long
getSecondLevelCacheHitCount()
The global number of cacheable entities and collections successfully retrieved from the cache.long
getSecondLevelCacheMissCount()
The global number of cacheable entities collections not found in the cache and loaded from the database.long
getSecondLevelCachePutCount()
The global number of cacheable entities and collections put in the cache.String[]
getSecondLevelCacheRegionNames()
All second-level cache region names.long
getSessionCloseCount()
The global number of sessions closed.long
getSessionOpenCount()
The global number of sessions opened.Map<String,Long>
getSlowQueries()
If "hibernate.log_slow_query" is enabled, a map from the SQL query to the maximum execution time in milliseconds.Instant
getStart()
long
getStartTime()
Deprecated.usegetStart()
long
getSuccessfulTransactionCount()
The number of transactions we know to have been successful.long
getTransactionCount()
The number of transactions we know to have completed.long
getUpdateTimestampsCacheHitCount()
The global number of timestamps successfully retrieved from cache.long
getUpdateTimestampsCacheMissCount()
The global number of timestamp requests that were not found in the cache.long
getUpdateTimestampsCachePutCount()
The global number of timestamps put in cache.boolean
isStatisticsEnabled()
Is collection of statistics enabled?void
logSummary()
Log the main statistics at levelINFO
.void
setStatisticsEnabled(boolean enabled)
Enable or disable statistics collection.
-
-
-
Field Detail
-
DEFAULT_QUERY_STATISTICS_MAX_SIZE
static final int DEFAULT_QUERY_STATISTICS_MAX_SIZE
The default value of the configuration property "hibernate.statistics.query_max_size".- See Also:
- Constant Field Values
-
-
Method Detail
-
isStatisticsEnabled
boolean isStatisticsEnabled()
Is collection of statistics enabled?
-
setStatisticsEnabled
void setStatisticsEnabled(boolean enabled)
Enable or disable statistics collection.
-
clear
void clear()
Reset all statistics.
-
logSummary
void logSummary()
Log the main statistics at levelINFO
.
-
getEntityStatistics
EntityStatistics getEntityStatistics(String entityName)
Obtain the statistics for the entity with the given name.- Parameters:
entityName
- the entity name
-
getCollectionStatistics
CollectionStatistics getCollectionStatistics(String role)
Obtain the statistics for the collection with the given role.- Parameters:
role
- the collection role
-
getNaturalIdStatistics
NaturalIdStatistics getNaturalIdStatistics(String entityName)
Obtain the natural id resolution statistics for the entity type with the given name.- Parameters:
entityName
- The entity name that is the root of the hierarchy containing the natural id
-
getQueryStatistics
QueryStatistics getQueryStatistics(String queryString)
Obtain the query statistics for the given query string.- Parameters:
queryString
- the query string, written in HQL or SQL
-
getDomainDataRegionStatistics
CacheRegionStatistics getDomainDataRegionStatistics(String regionName)
Obtain the second-level cache statistics for the given cache region.- Parameters:
regionName
- The unqualified region name- Returns:
- the statistics for the named region, or
null
if the second-level cache is not enabled - Throws:
IllegalArgumentException
- if there is no region with the given name
-
getQueryRegionStatistics
@Nullable CacheRegionStatistics getQueryRegionStatistics(String regionName)
Obtain the second-level cache statistics for the given query cache region.- Parameters:
regionName
- The unqualified region name- Returns:
- the statistics for the named region, or
null
if either query result caching is not enabled, or no query cache region exists with the given name
-
getCacheRegionStatistics
@Nullable CacheRegionStatistics getCacheRegionStatistics(String regionName)
Obtain the statistics for either a domain data or query result cache region.This method checks both, preferring the domain data region if there is one. Think of it as a cascading check to:
Note that null is returned instead of throwing an exception when no region exists with the given name.- Parameters:
regionName
- The unqualified region name- Returns:
- the statistics for the named region, or
null
if there is no region with the given name
-
getEntityDeleteCount
long getEntityDeleteCount()
The global number of entity deletes.
-
getEntityInsertCount
long getEntityInsertCount()
The global number of entity inserts.
-
getEntityLoadCount
long getEntityLoadCount()
The global number of entity loads.
-
getEntityFetchCount
long getEntityFetchCount()
The global number of entity fetches.
-
getEntityUpdateCount
long getEntityUpdateCount()
The global number of entity updates.
-
getQueryExecutionCount
long getQueryExecutionCount()
The global number of executed queries.
-
getQueryExecutionMaxTime
long getQueryExecutionMaxTime()
The time in milliseconds of the slowest query.
-
getQueryExecutionMaxTimeQueryString
@Nullable String getQueryExecutionMaxTimeQueryString()
The query string for the slowest query.
-
getQueryCacheHitCount
long getQueryCacheHitCount()
The global number of cached queries successfully retrieved from the cache.
-
getQueryCacheMissCount
long getQueryCacheMissCount()
The global number of cached queries notnot found in the cache.
-
getQueryCachePutCount
long getQueryCachePutCount()
The global number of cacheable queries put in cache.
-
getNaturalIdQueryExecutionCount
long getNaturalIdQueryExecutionCount()
The global number of natural id queries executed against the database.
-
getNaturalIdQueryExecutionMaxTime
long getNaturalIdQueryExecutionMaxTime()
The global maximum query time for natural id queries executed against the database.
-
getNaturalIdQueryExecutionMaxTimeRegion
@Nullable String getNaturalIdQueryExecutionMaxTimeRegion()
The region for the maximum natural id query time.
-
getNaturalIdQueryExecutionMaxTimeEntity
@Nullable String getNaturalIdQueryExecutionMaxTimeEntity()
The entity name for the maximum natural id query time.
-
getNaturalIdCacheHitCount
long getNaturalIdCacheHitCount()
The global number of cached natural id lookups successfully retrieved from the cache.
-
getNaturalIdCacheMissCount
long getNaturalIdCacheMissCount()
The global number of cached natural id lookups not found in the cache.
-
getNaturalIdCachePutCount
long getNaturalIdCachePutCount()
The global number of cacheable natural id lookups put in cache.
-
getUpdateTimestampsCacheHitCount
long getUpdateTimestampsCacheHitCount()
The global number of timestamps successfully retrieved from cache.
-
getUpdateTimestampsCacheMissCount
long getUpdateTimestampsCacheMissCount()
The global number of timestamp requests that were not found in the cache.
-
getUpdateTimestampsCachePutCount
long getUpdateTimestampsCachePutCount()
The global number of timestamps put in cache.
-
getFlushCount
long getFlushCount()
The global number of flush operations executed, including automatic (either manual or automatic).
-
getConnectCount
long getConnectCount()
The global number of connections requested by sessions.The actual number of connections used may be much smaller, assuming that a connection pool is in use.
-
getSecondLevelCacheHitCount
long getSecondLevelCacheHitCount()
The global number of cacheable entities and collections successfully retrieved from the cache.
-
getSecondLevelCacheMissCount
long getSecondLevelCacheMissCount()
The global number of cacheable entities collections not found in the cache and loaded from the database.
-
getSecondLevelCachePutCount
long getSecondLevelCachePutCount()
The global number of cacheable entities and collections put in the cache.
-
getSessionCloseCount
long getSessionCloseCount()
The global number of sessions closed.
-
getSessionOpenCount
long getSessionOpenCount()
The global number of sessions opened.
-
getCollectionLoadCount
long getCollectionLoadCount()
The global number of collections loaded.
-
getCollectionFetchCount
long getCollectionFetchCount()
The global number of collections fetched.
-
getCollectionUpdateCount
long getCollectionUpdateCount()
The global number of collections updated.
-
getCollectionRemoveCount
long getCollectionRemoveCount()
The global number of collections removed.
-
getCollectionRecreateCount
long getCollectionRecreateCount()
The global number of collections recreated
-
getStart
Instant getStart()
-
getStartTime
@Deprecated(since="6.0") long getStartTime()
Deprecated.usegetStart()
The Instant.toEpochMilli() milliseconds since the initial creation of this instance, or since the last timeclear()
was called.
-
getQueries
String[] getQueries()
All executed query strings.The maximum number of queries tracked by the Hibernate statistics is determined by the configuration property "hibernate.statistics.query_max_size".
-
getSlowQueries
Map<String,Long> getSlowQueries()
If "hibernate.log_slow_query" is enabled, a map from the SQL query to the maximum execution time in milliseconds.- Since:
- 6.3
- See Also:
JdbcSettings.LOG_SLOW_QUERY
-
getEntityNames
String[] getEntityNames()
The names of all entities.
-
getCollectionRoleNames
String[] getCollectionRoleNames()
The names of all collection roles.
-
getSecondLevelCacheRegionNames
String[] getSecondLevelCacheRegionNames()
All second-level cache region names. For backwards compatibility, this method returns just the names of regions storing domain data, not query result cache regions.
-
getSuccessfulTransactionCount
long getSuccessfulTransactionCount()
The number of transactions we know to have been successful.
-
getTransactionCount
long getTransactionCount()
The number of transactions we know to have completed.
-
getPrepareStatementCount
long getPrepareStatementCount()
The number of prepared statements that were acquired.
-
getCloseStatementCount
long getCloseStatementCount()
The number of prepared statements that were released.
-
getOptimisticFailureCount
long getOptimisticFailureCount()
The number of HibernateStaleObjectStateException
s or JPAOptimisticLockException
s that have occurred.
-
getQueryPlanCacheHitCount
long getQueryPlanCacheHitCount()
The global number of query plans successfully retrieved from cache.
-
getQueryPlanCacheMissCount
long getQueryPlanCacheMissCount()
The global number of query plans lookups not found in cache.
-
-