org.firebirdsql.management

## Class FBTableStatisticsManager

- java.lang.Object
- - org.firebirdsql.management.FBTableStatisticsManager

- All Implemented Interfaces:
    java.lang.AutoCloseable

      @Volatile(reason="Experimental")
      public final class FBTableStatisticsManager
      extends java.lang.Object
      implements java.lang.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 Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Clears the reference to the connection and clears the cache.
    `java.util.Map<java.lang.String,TableStatistics>` | `getTableStatistics()` Obtains a snapshot of the table statistics of this connection.
    `static FBTableStatisticsManager` | `of(java.sql.Connection connection)` Creates a table statistics manager for the current connection.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### of

          public static FBTableStatisticsManager of(java.sql.Connection connection)
                                             throws java.sql.SQLException

      Creates a table statistics manager for the current connection.
      Parameters:
        `connection` - Connection to gather statistics on.
      Returns:
        a table statistics manager
      Throws:
        `java.sql.SQLException` - if `connection` is closed

    - #### getTableStatistics

          public java.util.Map<java.lang.String,TableStatistics> getTableStatistics()
                                                                             throws java.sql.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)
        `java.sql.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 `java.lang.AutoCloseable`

Copyright © 2001-2025 Jaybird (Firebird JDBC) team. All rights reserved.