Record & Version Details
When you run gstat
with either the default switches, or [gstat-cmdline-data] or [gstat-cmdline-table] and add the [gstat-cmdline-record] switch, you get additional information in the report that shows the average record length and average version details for the table(s) in question:
Average record length: 96.55, total records: 62372 Average version length: 0.00, total versions: 0, max versions: 0
- Average record length
-
Simply the average record length, in bytes, of all the records in the table.If this figure is 0.00 then you can be reasonably sure that all your records have been deleted, or that you have no records in the table.
- Total records
-
The total number of records in the table.The value may include records in currently active transactions and may include records which have been deleted.
tux> # In session 1. tux> gstat test -r -t NORMAN ... Analyzing database pages ... NORMAN (142) Primary pointer page: 268, Index root page: 269 Average record length: 9.00, total records: 15 Average version length: 0.00, total versions: 0, max versions: 0 Data pages: 1, data page slots: 1, average fill: 10% tux> isql tset -user norman -password secret Database: employee SQL> SELECT COUNT(*) FROM NORMAN; COUNT ============ 15
At this point, we can see that there are 15 records in the
NORMAN
table and that the average length of these 15 records is 9.00 bytes.Next, we start anotherisql
session and delete all the records from theNORMAN
table.tux> # In session 2. tux> isql test -user norman -password secret Database: employee SQL> DELETE FROM NORMAN; SQL> COMMIT; SQL> shell;
Still in the second session, we execute
gstat
to fetch statistics for the NORMAN table, the results are shown below.tux> gstat test -r -t NORMAN ... Analyzing database pages ... NORMAN (142) Primary pointer page: 268, Index root page: 269 Average record length: 0.00, total records: 15 Average version length: 9.00, total versions: 15, max versions: 1 Data pages: 1, data page slots: 1, average fill: 16% ... tux> # Return to isql. tux> exit
Comparing the report above with the one taken before we deleted the records, we can see straight away that:
-
The average record length indicates that there are no records in the table, but the total record count shows that there are (still) 15.This is a good indicator that a session has deleted all the records but garbage collection has yet to run.
-
The versioning details have all changed, there are now statistics for average version length, total versions and max versions.
-
The average fill for the page(s) in this table has risen from 10% to 16% even though everything has been deleted.The extra space is being used by the back versions of the deleted records.
Continuing in the second session, if we execute a full table scan of the NORMAN table we will not see any results, but we will garbage collect the back versions.
SQL> SELECT * FROM NORMAN; SQL> shell; tux> gstat test -r -t NORMAN ... Analyzing database pages ... NORMAN (142) Primary pointer page: 268, Index root page: 269 Average record length: 0.00, total records: 0 Average version length: 0.00, total versions: 0, max versions: 0 Data pages: 0, data page slots: 0, average fill: 0%
Everything has now returned to zero.There are no back versions, no current versions and the page is no longer filled.
-
- Average version length
-
This is similar to the average record length, but for the back versions of the record.For example, if you have deleted a number of records and updated others, the old — back — versions of these records will be reported here.If the figure is 0.00 then garbage collection has taken place and removed the back versions — see above for an example.
- Total versions
-
The same as total records above, but includes only the back versions.If the figure is 0 then garbage collection has taken place and removed the back versions — see above for an example.
- Max versions
-
If a record has been updated many times, the max versions statistic shows you the number of back versions of the record (or records) in question.In a table where all the rows have been updated 7 times, but one has been updated 20 times, this statistic will report a value of 20.If the figure is 0.00 then garbage collection has taken place and removed the back versions — see above for an example.