Requesting Database and Server Status Reports

From InterBase

Go Up to Working with InterBase Services


TIBStatisticalService contains many properties and methods to allow you to build a statistical component into your application. Only the SYSDBA user or owner of the database will be able to run this service.

Requesting Database Statistics

Use the Options property of TIBStatisticalService to request database statistics. These options are incremental; that is, setting DbLog to <True> also returns HeaderPages statistics, setting IndexPages to <True> returns also returns DbLog and HeaderPages statistics, and so forth. Set any of the following options of type TStatOption to <True> to retrieve the appropriate information:

TIBStatisticalService options
Option Meaning

HeaderPages

Stop reporting statistics after reporting the information on the header page

DbLog

Stop reporting statistics after reporting information on the log pages

IndexPages

Request statistics for the user indexes in the database

DataPages

Request statistics for data tables in the database

SystemRelations

Request statistics for system tables and indexes in addition to user tables and indexes

To use the statistical service:

  1. Drop an IBStatisticalServices component on a Delphi form.
  2. Attach to the service manager as described in Attaching to a Service Manager.
  3. Set the DatabaseName property to the path of the database for which you would like statistics.
  4. Set the options for which statistics you would like to receive, either by setting them to <True> in the Object Inspector, or in code using the Options property.
  5. Start the statistical service using the ServiceStart method.

The following example displays the statistics for a database. With a button click, HeaderPages and DBLog statistics are returned until the end of the file is reached.

procedure TForm1.Button1Click(Sender: TObject);
begin
with IBStatisticalService1 do
begin
ServerName := 'Poulet';
DatabaseName := 'C:\InterBase\tutorial\tutorial.ib';
LoginPrompt := False;
Params.Add('user_name=sysdba');
Params.Add('password=masterkey');
Active := True;
ServiceStart;
try
Options := [DataPages, DBLog];
While not Eof do
Memo1.Lines.Add(GetNextLine);
finally
Active := False;
end;
end;
end;

Advance To: