HomeMogDBMogDB StackUqbar
v1.1

Documentation:v1.1

Supported Versions:

WDR Snapshot Schema

After the WDR snapshot function is enabled (enable_wdr_snapshot is set to on), schema snapshot is created in user tablespace pg_default in database postgres to flush WDR snapshot data.

You can set the parameter wdr_snapshot_retention_days to automatically manage the snapshot lifecycle.

Original Information Table of WDR Snapshots

SNAPSHOT.SNAPSHOT

SNAPSHOT records the index information, start time, and end time of WDR snapshots stored in the current system.

Table 1 SNAPSHOT attributes

Name Type Description Example
snapshot_id bigint WDR snapshot ID 1
start_ts timestamp Start time of a WDR snapshot 2019-12-28 17:11:27.423742+08
end_ts timestamp End time of a WDR snapshot 2019-12-28 17:11:43.67726+08

SNAPSHOT.TABLES_SNAP_TIMESTAMP

TABLES_SNAP_TIMESTAMP records the start time and end time of data collection, as well as corresponding databases, and table objects for all stored WDR snapshots.

Table 1 TABLES_SNAP_TIMESTAMP attributes

Name Type Description Example
snapshot_id bigint WDR snapshot ID 1
db_name text Database corresponding to a WDR snapshot tpcc1000
tablename text Table corresponding to a WDR snapshot snap_xc_statio_all_indexes
start_ts timestamp Start time of a WDR snapshot 2019-12-28 17:11:27.425849+08
end_ts timestamp End time of a WDR snapshot 2019-12-28 17:11:27.707398+08

WDR Snapshot Data Table

The naming rule of a WDR snapshot data table is snap_{Source data table}.

WDR snapshot data tables come from all views in DBE_PERF Schema.

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 MogDB
      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.
mogdb=# show enable_wdr_snapshot;
 enable_wdr_snapshot
---------------------
 on
(1 row)

-- Query the snapshots that have been generated.
mogdb=# 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.
mogdb=# \a \t \o /home/om/wdrTestNode.html
Output format is unaligned.
Showing only tuples.

-- Write data into the performance report wdrTestNode.html.
mogdb=# select generate_wdr_report(1, 2, 'all', 'node', 'dn');

-- Close the performance report wdrTestNode.html.
mogdb=# \o

-- Generate the formatted performance report wdrTestCluster.html.
mogdb=# \o /home/om/wdrTestCluster.html

-- Write data into the performance report wdrTestCluster.html.
mogdb=# select generate_wdr_report(1, 2, 'all', 'cluster', '');

-- Close the performance report wdrTestCluster.html.
mogdb=# \o \a \t
Output format is aligned.
Tuples only is off.
Copyright © 2011-2024 www.enmotech.com All rights reserved.