Abstract: In this article, you will learn what WDR is, how to create snapshots of performance data, and how to generate WDR reports.
This article is shared by Zhang Jingyao from The Performance Monitoring Report of WDR-gaussdb (DWS) in huawei Cloud community.
GaussDB(DWS) 8.1.1 introduces the Workload Diagnosis Report (WDR for short) function, which provides performance data within a specified period of time and presents it to users as an HTML Report. By analyzing the report, users can find exceptions, diagnose problems, and optimize performance. The report is rich in content and intuitive, and is a powerful tool for database tuning.
This paper briefly introduces the principle and usage of WDR. In this article, you will learn what WDR is, how to create snapshots of performance data, and how to generate WDR reports.
1. Introduction of WDR
WDR is a derivative of the GaussDB(DWS) database monitoring feature. The database kernel accumulates a large amount of first-hand data during its operation, such as the number of SQL executed, the number and time of accessing tables and indexes, and the running status of underlying hardware and software such as CPU and memory. Users can query the data in real time through the system view provided by the database. For example, query the PGXC_WORKLOAD_SQL_COUNT view to obtain the number of times each TYPE of SQL has been executed since the database started:
By saving these first-hand performance monitoring data and conducting automated statistical analysis, we need to know how the database is running during a certain period of time, such as whether it is busy, whether there is unreasonable SQL, what abnormal events, etc., so as to provide reference for problem diagnosis and performance tuning. This is where WDR comes in.
Figure 1 WDR principle
2. Create a performance snapshot
As described in the previous chapter, monitoring data should be preserved before being analyzed. For performance reasons, the database kernel keeps various monitoring data in memory for quick updates and reads. Once the process restarts, this data will be lost. Therefore, the first thing WDR does is to save the detection data in memory to the peripheral. The saved performance monitoring data is called snapshots, and the saving process is called creating snapshots.
Be careful not to confuse “Snapshot” here with the Snapshot of the database. The latter refers to the state of the data in the Database ata point in time, while WDR creates a “snapshot” that stores the contents of the system view queried ata point in time in a dedicated table.
Snapshots created by WDR are saved in the table under DBMS_OMSchema. Each system view corresponds to a table whose name = “DBMS_om.snap_” + view name. For example, the snapshot of the PGXC_WORKLOAD_SQL_COUNT view is saved in the DBMS_om. snap_PGXC_workload_SQL_COUNT table.
WDR supports snapshot creation in two ways. One is created periodically by the background thread. The interval is specified by the wdr_snapshot_interval parameter. The default interval is once every hour. The other is to run the create_wdr_snapshot system function to create the snapshot in real time. Note that this function requires administrator rights.
Either way, set the enable_wdr_snapshot parameter to ON.
Each time a snapshot is completed, rows are added to the snapshot related table under DBMS_OM. You can view the IDS and creation start and end time of existing snapshots in table dbMS_om. snapshot. Such as:
For example, snapshot 312 is created from 2021-05-29 12:36:32 to 2021-05-29 12:36:39. Snapshot_id is the unique id of each snapshot.
WDR creates snapshots for multiple system views at a time. You can query the start and end time of a snapshot for a single view by using the dbMS_om. tables_snap_TIMESTAMP table. Take the snapshot whose ID is 312 as an example:
Compared with DBMS_om. snapshot, table DBMS_om. tables_SNAP_TIMESTAMP records a more accurate snapshot time.
To avoid taking up too much space, snapshots that are too old are deleted periodically. The value ranges from 1 to 15 days by wdr_snapshot_retention_days. By default, snapshots created eight days ago are deleted. If you want to retain the snapshot data for a longer period, you need to dump the snapshot data by yourself.
3. Generate a WDR report
After a snapshot is created, you can calculate and analyze the performance monitoring data and generate a report for users to view. Different analysis angles and methods can produce different reports. Currently, WDR can compare the snapshot data of the first and second snapshots and generate a performance monitoring report (WDR Report for short) for this period.
As a distributed database, GaussDB(DWS) is composed of multiple nodes, which are classified into Coordinators (CN) and Datanodes (DN). Accordingly, WDR reports are divided into two scope types: cluster and node. The report contents of the two scopes are different. The former consists of the overall performance data of the cluster, while the latter analyzes and calculates the performance performance of a single node. For single-node scope reports, the report contents on CN and DN are also different. The report scope is specified by the user when the report is generated.
GaussDB(DWS) provides the system function generate_wDR_report () to create a WDR report. Before generating a report, determine the start and end snapshot_id. Query the DBMS_om. snapshot table and obtain the snapshot_id of the two time points in the time range you are interested in. For example, to view the performance between 2021-02-21 03:00:00 and 2021-02-21 04:00:00:
Based on the previous query, the start and end values of snapshot_id are 2147 and 2152 respectively.
Next, determine the type of report to generate. The current version supports generating three types of WDR: Summary, Detail, and All. Abstract type only includes brief analysis and calculation results, detailed type only includes detailed index data, and all type includes all contents of summary type and detailed type.
Finally, the generate_wDR_report () function is executed to generate the WDR report. For example, to generate a summary cluster-scoped WDR report between 2021-02-21 03:00:00 and 2021-02-21 04:00:00, execute:
To generate all types of WDR reports for node CN_5001 between 2021-02-21 03:00:00 and 2021-02-21 04:00:00, do the following:
If the file is successfully generated, $report file name has beengenerated is displayed. The report file is stored in the pg_log directory of the current CN node by default and can be opened using a web browser:
Figure 2. WDR report
Each part in the report is expanded by default. If you double click the title, relevant parts will collapse and the “-” before the title will become “+”, as shown in Figure 3:
Figure 3 Shows the collapsed WDR report style
For details about the indicators in the report, see the product documentation. How to use WDR reports to analyze and locate problems will be discussed in subsequent articles.
4. Precautions
As mentioned earlier, the WDR feature relies on various database kernel monitoring capabilities to provide data. For performance reasons, some kernel monitoring functions are turned off by default and need to be turned on with the GUC parameter. If this function is not enabled, the query result of the corresponding performance view is empty and snapshots and WDR reports cannot be generated. To get the full WDR report, set the GUC parameters in the following table to the values in the last column:
Want to know more information about GuassDB(DWS), welcome to wechat search “GaussDB DWS” follow the wechat public account, and share with you the latest and most complete PB series warehouse black technology, background can also obtain a lot of learning materials oh ~
Click follow to learn about the fresh technologies of Huawei Cloud