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

  1. Run the following command to query the generated snapshot and obtain snapshot_id:

    select * from snapshot.snapshot;
    
  2. (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();
    
  3. Perform the following steps to generate a performance report:

    1. 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.
    2. 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

      Parameter

      Description

      Value Range

      begin_snap_id

      ID of a snapshot when a query starts, which is specified by snapshot_id in the snapshot.snaoshot table.

      -

      end_snap_id

      ID of a snapshot when a query ends. By default, the value of end_snap_id is greater than that of begin_snap_id table.

      -

      report_type

      Type of the generated report. The value can be summary, detail, or all.

      • summary: Summary data
      • detail: Detailed data
      • all: summary data and detailed data

      report_scope

      Range of the generated report. The value can be cluster or node.

      • cluster: database-level information
      • node: node-level information

      node_name

      When report_scope is set to node, set this parameter to the name of the corresponding node. (You can run the select * from pg_node_env; command to query the node name.)

      If report_scope is set to cluster, this parameter can be omitted, left blank, empty or set to NULL.

      • node: a node name in openGauss
      • cluster: This value is omitted, left blank,empty or set to NULL.
    3. 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.
Feedback
编组 3备份
    openGauss 2024-05-06 00:44:54
    cancel