The gstat Command-line Tool
Go Up to Database Statistics and Connection Monitoring
gstat [<options>] <database>
Description: The
gstat
program is a command-line tool for retrieving and reporting database statistics. Its function is the same as that described for IBConsole earlier in this chapter.
You must be SYSDBA
or the owner of a database to run gstat
. On UNIX platforms, there is a further constraint on gstat
: in order to run gstat
, you must have system-level read access to the database files. You can gain this by logging in as the same account that the InterBase server is running as (InterBase or root) or by setting the system-level permissions on the database file to include read permission for your Group. These restrictions exist on UNIX platforms because gstat
accesses the database file at the system level rather than through the InterBase server.
You can run
gstat
only against local databases: run gstat
on the server host.Options: Table 1.5 lists the valid options for gstat:
Option | Description |
---|---|
- |
Equivalent to supplying - |
- |
Retrieves and displays statistics on data tables in the database. |
- |
Stops reporting statistics after reporting the information on the header page. |
- |
Retrieves and displays statistics on indexes in the database. |
- |
Stops reporting statistics after reporting the information on the log pages. |
- |
Checks for password <text> before accessing a database. |
|
Adds lines for average record length and average version length to the table statistics. |
- |
Retrieves statistics on system tables and indexes in addition to user tables and indexes. |
|
Outputs index and fill information for the requested table, in addition to database header, file, and log statistics; table name is case sensitive. |
- |
Checks for user <name> before accessing database. |
- |
Prints product version of |
Example: The following command requests table statistics, including record and version length for the JOB
table in employee.ib
:
gstat -user SYSDBA -pa masterkey employee.ib -t JOB -r
The command produces the following output:
Database "employee.ib" Database header page information: Flags 0 Checksum 12345 Write timestamp Jul 9, 2010 19:58:59 Generation 26 Page size 4096 ODS version 15.0 Oldest transaction 19 Oldest active 20 Oldest snapshot 20 Next transaction 21 Sequence number 0 Next attachment ID 0 Implementation ID 16 Shadow count 0 Page buffers 0 Next header page 0 Database dialect 1 Creation date Jul 9, 2010 19:58:59 Attributes force write variable header data: Sweep interval: 20000 *END* Database file sequence: File employee.ib is the only file Database log page information: Creation date Log flags: 2 No write ahead log Next log page: 0 variable log data: Control Point 1: File name: Partition offset: 0 Seqno: 0 Offset: 0 Control Point 2: File name: Partition offset: 0 Seqno: 0 Offset: 0 Current File: File name: Partition offset: 0 Seqno: 0 Offset: 0 *END* Analyzing database pages ... JOB (129) Primary pointer page: 178, Index root page: 179 Average record length: 64.87, total records: 31, max record length: 77 Average version length: 0.00, total versions: 0, max versions: 0 Data pages: 3, data page slots: 3, average fill: 72% Fill distribution: 0 - 19% = 0 20 - 39% = 1 40 - 59% = 0 60 - 79% = 0 80 - 99% = 2 Blob pointer page: 253 Average blob length: 535.27, total blobs: 11, max blob length: 4598 Average segment length: 33.83, total segments: 175, max segment length:85 Blob pages: 1, blob page slots: 1, average fill: 41% Fill distribution: 0 - 19% = 0 20 - 39% = 0 40 - 59% = 1 60 - 79% = 0 80 - 99% = 0 Index MAXSALX (2) Depth: 1, leaf buckets: 1, nodes: 31 Average data length: 4.00, total dup: 5, max dup: 1 Fill distribution: 0 - 19% = 1 20 - 39% = 0 40 - 59% = 0 60 - 79% = 0 80 - 99% = 0 Index MINSALX (1) Depth: 1, leaf buckets: 1, nodes: 31 Average data length: 4.00, total dup: 7, max dup: 2 Fill distribution: 0 - 19% = 1 20 - 39% = 0 40 - 59% = 0 60 - 79% = 0 80 - 99% = 0 Index RDB$FOREIGN3 (3) Depth: 1, leaf buckets: 1, nodes: 31 Average data length: 1.00, total dup: 24, max dup: 20 Fill distribution: 0 - 19% = 1 20 - 39% = 0 40 - 59% = 0 60 - 79% = 0 80 - 99% = 0 Index RDB$PRIMARY2 (0) Depth: 1, leaf buckets: 1, nodes: 31 Average data length: 10.00, total dup: 0, max dup: 0 Fill distribution: 0 - 19% = 1 20 - 39% = 0 40 - 59% = 0 60 - 79% = 0 80 - 99% = 0