Class FBStatisticsManager

java.lang.Object
org.firebirdsql.management.FBServiceManager
org.firebirdsql.management.FBStatisticsManager
All Implemented Interfaces:
AttachmentProperties, BaseProperties, ServiceConnectionProperties, ServiceManager, StatisticsManager

public class FBStatisticsManager extends FBServiceManager implements StatisticsManager
The FBStatisticsManager class is responsible for replicating the functionality of the gstat command-line tool.

This functionality includes:

  • Retrieving data table statistics
  • Retrieving the database header page
  • Retrieving index statistics
  • Retrieving database logging information
  • Retrieving statistics for the data dictionary

Author:
Gabriel Reid
  • Constructor Details

    • FBStatisticsManager

      public FBStatisticsManager()
      Create a new instance of FBMaintenanceManager based on the default GDSType.
    • FBStatisticsManager

      public FBStatisticsManager(String gdsType)
      Create a new instance of FBMaintenanceManager based on a given GDSType.
      Parameters:
      gdsType - type must be PURE_JAVA, EMBEDDED, or NATIVE
    • FBStatisticsManager

      public FBStatisticsManager(GDSType gdsType)
      Create a new instance of FBMaintenanceManager based on a given GDSType.
      Parameters:
      gdsType - The GDS implementation type to use
  • Method Details

    • getHeaderPage

      public void getHeaderPage() throws SQLException
      Description copied from interface: StatisticsManager
      Fetch the database statistics header page.

      The header information is written to this StatisticsManager's logger.

      Specified by:
      getHeaderPage in interface StatisticsManager
      Throws:
      SQLException - if a database access error occurs
    • getDatabaseStatistics

      public void getDatabaseStatistics() throws SQLException
      Description copied from interface: StatisticsManager
      Get the full database statistics information, excluding system table information.

      The statistics information is written to this StatisticsManager's logger.

      The listed data includes:

      • statistics header page
      • log statistics
      • index statistics
      • data table statistics

      Invoking this method is equivalent to the default behaviour of gstat on the command-line.

      Specified by:
      getDatabaseStatistics in interface StatisticsManager
      Throws:
      SQLException - if a database access error occurs
    • getDatabaseStatistics

      public void getDatabaseStatistics(int options) throws SQLException
      Description copied from interface: StatisticsManager
      Get specific database statistics.

      The statistics information is written to this StatisticsManager's logger. All invocations of this method will result in the header page and log data being output.

      The following options can be supplied as a bitmask:

      • DATA_TABLE_STATISTICS
      • SYSTEM_TABLE_STATISTICS
      • INDEX_STATISTICS
      • RECORD_VERSION_STATISTICS

      If this method is invoked with 0 as the options value, only the header and log statistics will be output.

      Specified by:
      getDatabaseStatistics in interface StatisticsManager
      Parameters:
      options - A bitmask combination of DATA_TABLE_STATISTICS, SYSTEM_TABLE_STATISTICS, INDEX_STATISTICS, or RECORD_VERSION_STATISTICS. Can also be 0, which is equivalent to calling method StatisticsManager.getDatabaseStatistics()
      Throws:
      SQLException
    • getTableStatistics

      public void getTableStatistics(String[] tableNames) throws SQLException
      Description copied from interface: StatisticsManager
      Get the table statistics.

      The statistics information is written to this StatisticsManager's logger.

      The listed data includes:

      • the primary pointer and index root page numbers
      • number of data pages and their average fill
      • fill distribution

      Invoking this method is equivalent to the behaviour of gstat -t <table name> on the command-line.

      Specified by:
      getTableStatistics in interface StatisticsManager
      Parameters:
      tableNames - array of table names to analyze.
      Throws:
      SQLException - if something went wrong.
    • getDatabaseTransactionInfo

      public StatisticsManager.DatabaseTransactionInfo getDatabaseTransactionInfo() throws SQLException
      Description copied from interface: StatisticsManager
      Get transaction information of the database specified in database.
      Specified by:
      getDatabaseTransactionInfo in interface StatisticsManager
      Returns:
      Database transaction information
      Throws:
      SQLException - If database is not specified, or for failures to connect or retrieve information
    • getDatabaseTransactionInfo

      public static StatisticsManager.DatabaseTransactionInfo getDatabaseTransactionInfo(Connection connection) throws SQLException
      Get transaction information for an existing database connection.
      Parameters:
      connection - Database connection; must unwrap to FirebirdConnection.
      Returns:
      Database transaction information
      Throws:
      SQLException - If connection does not unwrap to FirebirdConnection, or for failures to retrieve information
      Since:
      3