Performance Report Generated Based on WDR Snapshot
A performance report is generated by summarizing and collecting statistics based on WDR snapshot data tables.
Prerequisites
A report can be generated after the WDR snapshot function is enabled (that is, enable_wdr_snapshot is set to on) and the number of snapshots is greater than or equal to 2.
Procedure
Run the following command to query the generated snapshot and obtain snapshot_id:
select * from snapshot.snapshot;
(Optional) Run the following command to manually create a snapshot. If only one snapshot exists in the database or to view the monitoring data of the database in the current period, manually create a snapshot.
select create_wdr_snapshot();
Perform the following steps to generate a performance report:
Run the following command to generate a formatted performance report file:
\a \t \o Server file path
The parameters in the preceding command are described as follows:
- \a: switches the unaligned mode.
- \t: switches the information and row count footer of the output column name.
- \o: specifies that all the query results are sent to the server file.
- Server file path: indicates the path for storing the generated performance report file. The user must have the read and write permissions on the path.
Run the following command to write the queried information to the performance report:
select generate_wdr_report(begin_snap_id Oid, end_snap_id Oid, varchar report_type, varchar report_scope, int node_name );
The description of the parameters in the preceding command is as follows:
Table 1 Parameters of the generate_wdr_report function
Run the following commands to disable the output options and format the output:
\o \a \t
Examples
-- To query enable_wdr_snapshot, set this parameter to on.
postgres=# show enable_wdr_snapshot;
enable_wdr_snapshot
---------------------
on
(1 row)
-- Query the snapshots that have been generated.
postgres=# select * from snapshot.snapshot;
snapshot_id | start_ts | end_ts
-------------+-------------------------------+-------------------------------
1 | 2020-09-07 10:20:36.763244+08 | 2020-09-07 10:20:42.166511+08
2 | 2020-09-07 10:21:13.416352+08 | 2020-09-07 10:21:19.470911+08
(2 rows)
-- Generate the formatted performance report wdrTestNode.html.
postgres=# \a \t \o /home/om/wdrTestNode.html
Output format is unaligned.
Showing only tuples.
-- Write data into the performance report wdrTestNode.html.
postgres=# select generate_wdr_report(1, 2, 'all', 'node', 'dn');
-- Close the performance report wdrTestNode.html.
postgres=# \o
-- Generate the formatted performance report wdrTestCluster.html.
postgres=# \o /home/om/wdrTestCluster.html
-- Write data into the performance report wdrTestCluster.html.
postgres=# select generate_wdr_report(1, 2, 'all', 'cluster', '');
-- Close the performance report wdrTestCluster.html.
postgres=# \o \a \t
Output format is aligned.
Tuples only is off.