Class FBTableStatisticsManager

java.lang.Object
org.firebirdsql.management.FBTableStatisticsManager
All Implemented Interfaces:
AutoCloseable

@Volatile(reason="Experimental") public final class FBTableStatisticsManager extends Object implements AutoCloseable
Provides access to the table statistics of a Connection.

The table statistics are execution statistics of the specific connection, and are not global statistics.

This manager retains a reference to underlying FbDatabase instance and holds a cache of table names. Closing this manager will remove the reference the database handle (but not close it!) and releases the cache.

This class is not thread-safe (though its use of the underlying connection is thread-safe).

Since:
5
Author:
Mark Rotteveel
  • Method Details

    • of

      public static FBTableStatisticsManager of(Connection connection) throws SQLException
      Creates a table statistics manager for the current connection.
      Parameters:
      connection - Connection to gather statistics on.
      Returns:
      a table statistics manager
      Throws:
      SQLException - if connection is closed
    • getTableStatistics

      public Map<String,TableStatistics> getTableStatistics() throws SQLException
      Obtains a snapshot of the table statistics of this connection.

      A table is only present in the map if this connection touched it in a way which generated a statistic.

      Returns:
      map from table name to table statistics
      Throws:
      InfoTruncatedException - if a truncated response is received, after retrying 3 times (total: 4 attempts) while increasing the buffer size; it is possible that subsequent calls to this method may recover (as that will increase the buffer size even more)
      SQLException - if the connection is closed, or if obtaining the statistics failed due to a database access error
    • close

      public void close()
      Clears the reference to the connection and clears the cache.

      This method does not close the connection wrapped by this manager.

      Closing a table statistics manager is not required. It can be used to clean up early, or to prevent a user of this class from gathering further statistics.

      Specified by:
      close in interface AutoCloseable