Simulating Statspack AWR reports v16
When taking a snapshot, performance data from system catalog tables is saved into history tables. The following functions return information comparable to the information contained in an Oracle Statspack/Automatic Workload Repository (AWR) report. These reporting functions report on the differences between two given snapshots:
stat_db_rpt()
stat_tables_rpt()
statio_tables_rpt()
stat_indexes_rpt()
statio_indexes_rpt()
You can execute the reporting functions individually or you can execute all five functions by calling the edbreport()
function.
edbreport()
The edbreport()
function includes data from the other reporting functions, plus system information. The signature is:
Parameters
beginning_id
An integer value that represents the beginning session identifier.
ending_id
An integer value that represents the ending session identifier.
The call to the edbreport()
function returns a composite report that contains system information and the reports returned by the other statspack functions:
Report introduction
The information displayed in the report introduction includes the database name and version, the current date, the beginning and ending snapshot date and times, database and tablespace details, and schema information.
Top 10 Relations by pages
The information displayed in the Top 10 Relations by pages
section includes:
Column name | Description |
---|---|
TABLE | The name of the table |
RELPAGES | The number of pages in the table |
Top 10 Indexes by pages
The information displayed in the Top 10 Indexes by pages
section includes:
Column name | Description |
---|---|
INDEX | The name of the index |
RELPAGES | The number of pages in the index |
Top 10 Relations by DML
The information displayed in the Top 10 Relations by DML
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the table resides |
RELATION | The name of the table |
UPDATES | The number of UPDATES performed on the table |
DELETES | The number of DELETES performed on the table |
INSERTS | The number of INSERTS performed on the table |
DATA from pg_stat_database
The information displayed in the DATA from pg_stat_database
section of the report includes:
Column name | Description |
---|---|
DATABASE | The name of the database. |
NUMBACKENDS | Number of backends currently connected to this database. This is the only column in this view that returns a value reflecting current state. All other columns return the accumulated values since the last reset. |
XACT COMMIT | Number of transactions in this database that were committed. |
XACT ROLLBACK | Number of transactions in this database that were rolled back. |
BLKS READ | Number of disk blocks read in this database. |
BLKS HIT | Number of times disk blocks were found already in the buffer cache when a read wasn't necessary. |
HIT RATIO | The percentage of times that a block was found in the shared buffer cache. |
DATA from pg_buffercache
The information displayed in the DATA from pg_buffercache
section of the report includes:
Column name | Description |
---|---|
RELATION | The name of the table |
BUFFERS | The number of shared buffers used by the relation |
Note
To obtain the report for DATA from pg_buffercache
, the pg_buffercache
module must be installed in the database. Perform the installation using the CREATE EXTENSION
command.
For more information on the CREATE EXTENSION
command, see the PostgreSQL core documentation.
DATA from pg_stat_all_tables ordered by seq scan
The information displayed in the DATA from pg_stat_all_tables ordered by seq scan
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the table resides |
RELATION | The name of the table |
SEQ SCAN | The number of sequential scans initiated on this table |
REL TUP READ | The number of tuples read in the table |
IDX SCAN | The number of index scans initiated on the table |
IDX TUP READ | The number of index tuples read |
INS | The number of rows inserted |
UPD | The number of rows updated |
DEL | The number of rows deleted |
DATA from pg_stat_all_tables ordered by rel tup read
The information displayed in the DATA from pg_stat_all_tables ordered by rel tup read
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the table resides |
RELATION | The name of the table |
SEQ SCAN | The number of sequential scans performed on the table |
REL TUP READ | The number of tuples read from the table |
IDX SCAN | The number of index scans performed on the table |
IDX TUP READ | The number of index tuples read |
INS | The number of rows inserted |
UPD | The number of rows updated |
DEL | The number of rows deleted |
DATA from pg_statio_all_tables
The information displayed in the DATA from pg_statio_all_tables
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the table resides |
RELATION | The name of the table |
HEAP READ | The number of heap blocks read |
HEAP HIT | The number of heap blocks hit |
IDX READ | The number of index blocks read |
IDX HIT | The number of index blocks hit |
TOAST READ | The number of toast blocks read |
TOAST HIT | The number of toast blocks hit |
TIDX READ | The number of toast index blocks read |
TIDX HIT | The number of toast index blocks hit |
DATA from pg_stat_all_indexes
The information displayed in the DATA from pg_stat_all_indexes
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the index resides |
RELATION | The name of the table on which the index is defined |
INDEX | The name of the index |
IDX SCAN | The number of indexes scans initiated on this index |
IDX TUP READ | Number of index entries returned by scans on this index |
IDX TUP FETCH | Number of live table rows fetched by simple index scans using this index |
DATA from pg_statio_all_indexes
The information displayed in the DATA from pg_statio_all_indexes
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the index resides |
RELATION | The name of the table on which the index is defined |
INDEX | The name of the index |
IDX BLKS READ | The number of index blocks read |
IDX BLKS HIT | The number of index blocks hit |
System Wait Information
The information displayed in the System Wait Information
section includes:
Column name | Description |
---|---|
WAIT NAME | The name of the wait |
COUNT | The number of times that the wait event occurred |
WAIT TIME | The length of the wait time in seconds |
% WAIT | The percentage of the total wait time used by this wait for this session |
Database Parameters from postgresql.conf
The information displayed in the Database Parameters from postgresql.conf
section includes:
Column name | Description |
---|---|
PARAMETER | The name of the parameter |
SETTING | The current value assigned to the parameter |
CONTEXT | The context required to set the parameter value |
MINVAL | The minimum value allowed for the parameter |
MAXVAL | The maximum value allowed for the parameter |
stat_db_rpt()
The signature is:
Parameters
beginning_id
An integer value that represents the beginning session identifier.
ending_id
An integer value that represents the ending session identifier.
This example shows the stat_db_rpt()
function:
DATA from pg_stat_database
The information displayed in the DATA from pg_stat_database
section of the report includes:
Column name | Description |
---|---|
DATABASE | The name of the database. |
NUMBACKENDS | Number of backends currently connected to this database. This is the only column in this view that returns a value reflecting current state. All other columns return the accumulated values since the last reset. |
XACT COMMIT | The number of transactions in this database that were committed. |
XACT ROLLBACK | The number of transactions in this database that were rolled back. |
BLKS READ | The number of blocks read. |
BLKS HIT | The number of blocks hit. |
HIT RATIO | The percentage of times that a block was found in the shared buffer cache. |
stat_tables_rpt()
The signature is:
Parameters
beginning_id
An integer value that represents the beginning session identifier.
ending_id
An integer value that represents the ending session identifier.
top_n
The number of rows to return.
scope
Determines the tables the function returns statistics about. Specify SYS
, USER
, or ALL
:
- Use
SYS
to return information about system-defined tables. A table is considered a system table if it's stored in thepg_catalog
,information_schema
, orsys
schema. - Use
USER
to return information about user-defined tables. - Use
ALL
to return information about all tables.
The stat_tables_rpt()
function returns a two-part report. The first portion of the report contains:
DATA from pg_stat_all_tables ordered by seq scan
The information displayed in the DATA from pg_stat_all_tables ordered by seq scan
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the table resides |
RELATION | The name of the table |
SEQ SCAN | The number of sequential scans on the table |
REL TUP READ | The number of tuples read from the table |
IDX SCAN | The number of index scans performed on the table |
IDX TUP READ | The number of index tuples read from the table |
INS | The number of rows inserted |
UPD | The number of rows updated |
DEL | The number of rows deleted |
The second portion of the report contains:
DATA from pg_stat_all_tables ordered by rel tup read
The information displayed in the DATA from pg_stat_all_tables ordered by rel tup read
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the table resides |
RELATION | The name of the table |
SEQ SCAN | The number of sequential scans performed on the table |
REL TUP READ | The number of tuples read from the table |
IDX SCAN | The number of index scans performed on the table |
IDX TUP READ | The number of live rows fetched by index scans |
INS | The number of rows inserted |
UPD | The number of rows updated |
DEL | The number of rows deleted |
statio_tables_rpt()
The signature is:
Parameters
beginning_id
An integer value that represents the beginning session identifier.
ending_id
An integer value that represents the ending session identifier.
top_n
The number of rows to return.
scope
Determines the tables the function returns statistics about. Specify SYS
, USER
or ALL
:
- Use
SYS
to return information about system-defined tables. A table is considered a system table if it's stored thepg_catalog
,information_schema
, orsys
schema. - Use
USER
to return information about user-defined tables. - Use
ALL
to return information about all tables.
The statio_tables_rpt()
function returns a report that contains:
DATA from pg_statio_all_tables
The information displayed in the DATA from pg_statio_all_tables
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the relation resides |
RELATION | The name of the relation |
HEAP READ | The number of heap blocks read |
HEAP HIT | The number of heap blocks hit |
IDX READ | The number of index blocks read |
IDX HIT | The number of index blocks hit |
TOAST READ | The number of toast blocks read |
TOAST HIT | The number of toast blocks hit |
TIDX READ | The number of toast index blocks read |
TIDX HIT | The number of toast index blocks hit |
stat_indexes_rpt()
The signature is:
Parameters
beginning_id
An integer value that represents the beginning session identifier.
ending_id
An integer value that represents the ending session identifier.
top_n
The number of rows to return.
scope
Determines the tables the function returns statistics about. Specify SYS
, USER
or ALL
:
- Use
SYS
to return information about system-defined tables. A table is considered a system table if it's stored in thepg_catalog
,information_schema
, orsys
schema. - Use
USER
to return information about user-defined tables. - Use
ALL
to return information about all tables.
The stat_indexes_rpt()
function returns a report that contains:
DATA from pg_stat_all_indexes
The information displayed in the DATA from pg_stat_all_indexes
section includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the relation resides |
RELATION | The name of the relation |
INDEX | The name of the index |
IDX SCAN | The number of indexes scanned |
IDX TUP READ | The number of index tuples read |
IDX TUP FETCH | The number of index tuples fetched |
statio_indexes_rpt()
The signature is:
Parameters
beginning_id
An integer value that represents the beginning session identifier.
ending_id
An integer value that represents the ending session identifier.
top_n
The number of rows to return.
scope
Determines the tables the function returns statistics about. Specify SYS
, USER
or ALL
:
- Use
SYS
to return information about system-defined tables. A table is considered a system table if it's stored in thepg_catalog
,information_schema
, orsys
schema. - Use
USER
to return information about user-defined tables. - Use
ALL
to return information about all tables.
The statio_indexes_rpt()
function returns a report that contains:
DATA from pg_statio_all_indexes
The information displayed in the DATA from pg_statio_all_indexes
report includes:
Column name | Description |
---|---|
SCHEMA | The name of the schema in which the relation resides |
RELATION | The name of the table on which the index is defined |
INDEX | The name of the index |
IDX BLKS READ | The number of index blocks read |
IDX BLKS HIT | The number of index blocks hit |