postgresql performance analysis tool-pgstatpack-2.3.3.1

I. Introduction

The performance monitoring and status discrimination during the daily operation of the database is one of the important parts of the daily operation and maintenance of the database. It is also an important proof for us to troubleshoot database performance problems and optimize the system.
The Oracle database collects and counts information on the operating status and performance of the database for a certain period of time through the AWR report and the ASH report, and then determines the bottleneck of the database operating performance during this period. At its root, Oracle will collect the non-idle waiting event information and session information of the current database every 1s (default), and store them in the relevant ASH view. The AWR report is hourly (default, configurable), and saves a snapshot of the database’s running status. When performing performance analysis, you can obtain the running status of the database within a period of time through awr-related views or awr reports. . Before 9i, AWR was called statpack. After 9i, it was officially named awr.
But for postgreSQL, there is currently no function similar to AWR integrated in it. Therefore, for PostgreSQL, we can only use other toolkits to realize this function, so as to help us better monitor and obtain the performance of the postgreSQL database within a period of time.

2. Tool download address

Pgstatpack is a very good performance analysis tool for PostgreSQL. It is easy to deploy and easy to use. You can save snapshots of the PostgreSQL database by enabling scheduled tasks to help users perform comparison and analysis.
Currently, the version we can download is: pgstatpack-2.3.3
download address:
http://www.xenialab.it/meo/web/pub/pgstatspack-2.3.3.zip
But in the process of using the test, we found that The content of the version part is not particularly complete, such as snapshot information such as tables, sql, and indexes are not collected.
Therefore, in the process of using, in order to be closer to the actual use, I further optimized the toolkit of this version, perfected the report content, table collection content, view collection content, as well as generating snapshots, deleting snapshots, and generating reports script.
New version download address:
https://pan.baidu.com/s/1HhFkd0kL8G7PqVYW5YFCLg
Verification code: alda
(you can download it directly and use it, and modify it according to the actual situation).

3. Use of tools

1 Introduction

Next, I will give a brief introduction to the installation and usage of the tool:
In this tool, the core files are mainly as follows:
1. In the folder bin, there are three .sh scripts
snapshot.sh
delete_snapshot .sh
pgstatpack_report.sh
Among them,
the snapshot.sh script is set through the crontab of the linux host, and the script can be executed regularly to collect snapshots for postgresql to record the database operation at the moment of the snapshot; the delete_snapshot.sh script is also set through
Linux The crontab of the host machine is set, and the script can be executed regularly. Delete historical snapshots for the postgresql database;
the pgstatpack_report.sh script can be executed directly to obtain the information in the relevant snapshots and generate the database operation status during the two snapshots, similar to the AWR report of oracle.
2. The sql folder The folder sql mainly stores the table information, view information, and functions for creating snapshots, deleting snapshots, and obtaining basic information about tool installation.
The main files are as follows:
pgstatspack_create_snap.sql, used to create snapshot generation function
pgstatspack_create_tables.sql, used to create snapshot related tables and views, for installation
pgstatspack_delete_old_stats.sql, used to create and delete snapshot function
pgstatspack_remove_tables.sql, used to delete snapshot table, Do uninstall with
3.install_pgstats.sh
This script is mainly used to install tools
4.pgstatspack_stat_explanation.txt
This text is to explain each parameter

2) install

1. Unzip the package

unzip pgstatspack-2.3.3.1.zip

2. Execute the script installation script using a user with superadmin privileges on the Postgres database:

sh install_pgstats.sh

Just enter the postgresql port

3) use

For ease of use, we first need to deploy the pg_stat_statements plugin

Specify a scheduled task to collect snapshots:
crontab -e

#每分钟执行一次
/1 * * * * sh snapshot.sh
#所有快照保存30天
* 30 * * * * sh delete_snapshot.sh

Generate report:

sh pgstatpack_report.sh

Enter the database name and database port to generate the report.

4. Examples

After the installation is successful, the following tables, views, and sequences will exist in each database you can see

postgres=# \d
                    List of relations
 Schema |           Name            |   Type   |  Owner   
--------+---------------------------+----------+----------
 public | pg_stat_statements        | view     | postgres
 public | pgstatspack_activity      | table    | postgres
 public | pgstatspack_activity_v    | view     | postgres
 public | pgstatspack_bgwriter      | table    | postgres
 public | pgstatspack_database      | table    | postgres
 public | pgstatspack_database_v    | view     | postgres
 public | pgstatspack_functions     | table    | postgres
 public | pgstatspack_functions_v   | view     | postgres
 public | pgstatspack_indexes       | table    | postgres
 public | pgstatspack_indexes_v     | view     | postgres
 public | pgstatspack_names         | table    | postgres
 public | pgstatspack_sequences     | table    | postgres
 public | pgstatspack_sequences_v   | view     | postgres
 public | pgstatspack_settings      | table    | postgres
 public | pgstatspack_settings_v    | view     | postgres
 public | pgstatspack_snap          | table    | postgres
 public | pgstatspack_space_usage   | table    | postgres
 public | pgstatspack_space_usage_v | view     | postgres
 public | pgstatspack_statements    | table    | postgres
 public | pgstatspack_statements_v  | view     | postgres
 public | pgstatspack_tables        | table    | postgres
 public | pgstatspack_tables_v      | view     | postgres
 public | pgstatspack_version       | table    | postgres
 public | pgstatspackid             | sequence | postgres
 public | pgstatspacknameid         | sequence | postgres
(25 rows)

Generate report example:

[postgres@postgresql11 bin]$ sh pgstatspack_report.sh
/home/soft/pgstatspack-2.3.3.1/bin /home/soft/pgstatspack-2.3.3.1/bin
Please specify a username: 
postgres
Please specify a port: 
15432
List of available databases:

1 .  postgres
2 .  wangxin
3 .  wangxin1

Please select a number from the above list [ 1 -  3 ] 
1
psql: invalid port number: "PGPORT"
pgstatspack_report.sh: line 129: [: -eq: unary operator expected
pgstatspack_report.sh: line 143: [: -lt: unary operator expected
 snapid |             ts             |     description     
--------+----------------------------+---------------------
     76 | 2020-11-06 17:22:01.172027 | cron based snapshot
     75 | 2020-11-06 17:21:01.933611 | cron based snapshot
     74 | 2020-11-06 17:20:01.253815 | cron based snapshot
     42 | 2020-11-06 16:18:02.007747 | cron based snapshot
     41 | 2020-11-06 16:17:01.780944 | cron based snapshot
     40 | 2020-11-06 16:16:01.556158 | cron based snapshot
     39 | 2020-11-06 16:15:01.337829 | cron based snapshot
     38 | 2020-11-06 16:14:01.097114 | cron based snapshot
     37 | 2020-11-06 16:13:01.866499 | cron based snapshot
     36 | 2020-11-06 16:12:01.616422 | cron based snapshot
     35 | 2020-11-06 16:11:01.336428 | cron based snapshot
     34 | 2020-11-06 16:10:02.075392 | cron based snapshot
     33 | 2020-11-06 16:09:01.828527 | cron based snapshot
     32 | 2020-11-06 16:08:01.539675 | cron based snapshot
     31 | 2020-11-06 16:07:01.246791 | cron based snapshot
     30 | 2020-11-06 16:06:01.994279 | cron based snapshot
     29 | 2020-11-06 16:05:01.697285 | cron based snapshot
     28 | 2020-11-06 16:04:01.412084 | cron based snapshot
     27 | 2020-11-06 16:03:02.09771  | cron based snapshot
     26 | 2020-11-06 16:02:01.81457  | cron based snapshot
     25 | 2020-11-06 16:01:01.515131 | cron based snapshot
     24 | 2020-11-06 16:00:01.134459 | cron based snapshot
     23 | 2020-11-06 15:59:01.840724 | cron based snapshot
     22 | 2020-11-06 15:58:01.594782 | cron based snapshot
     21 | 2020-11-06 15:57:01.262691 | cron based snapshot
     20 | 2020-11-06 15:56:02.03767  | cron based snapshot
     19 | 2020-11-06 15:55:01.688383 | cron based snapshot
     18 | 2020-11-06 15:54:01.384491 | cron based snapshot
     17 | 2020-11-06 15:53:01.131956 | cron based snapshot
     16 | 2020-11-06 15:52:01.885006 | cron based snapshot
     15 | 2020-11-06 15:51:01.602279 | cron based snapshot
     14 | 2020-11-06 15:50:01.343534 | cron based snapshot
     13 | 2020-11-06 15:49:01.105154 | cron based snapshot
     12 | 2020-11-06 15:48:01.88585  | cron based snapshot
     11 | 2020-11-06 15:47:01.648536 | cron based snapshot
     10 | 2020-11-06 15:46:01.401738 | cron based snapshot
      9 | 2020-11-06 15:45:01.136869 | cron based snapshot
      8 | 2020-11-06 15:44:01.865318 | cron based snapshot
      7 | 2020-11-06 15:43:57.590552 | cron based snapshot
      6 | 2020-11-05 17:39:01.714187 | cron based snapshot
      5 | 2020-11-05 17:38:01.48115  | cron based snapshot
      4 | 2020-11-05 17:37:01.232256 | cron based snapshot
      3 | 2020-11-05 17:36:02.012466 | cron based snapshot
      2 | 2020-11-05 17:35:01.762274 | cron based snapshot
      1 | 2020-11-05 17:34:01.473805 | cron based snapshot
(45 rows)

Enter start snapshot id : 75
Enter stop snapshot id  : 76
Using file name: /tmp/pgstatreport_postgres_75_76.txt
###########################################################################################################
PGStatspack version 2.3.3.1 by [email protected]
###########################################################################################################

Snapshot information
Begin snapshot : 
 snapid |             ts             |     description     
--------+----------------------------+---------------------
     75 | 2020-11-06 17:21:01.933611 | cron based snapshot
(1 row)

End snapshot   :
 snapid |             ts             |     description     
--------+----------------------------+---------------------
     76 | 2020-11-06 17:22:01.172027 | cron based snapshot
(1 row)

Seconds in snapshot:  59.238416


Database version
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 11.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
(1 row)

Database information
 current_database | dbsize 
------------------+--------
 postgres         | 181 MB
(1 row)


Database statistics
 database  | tps | hitrate | lio_ps | pio_ps | rollbk_ps 
-----------+-----+---------+--------+--------+-----------
 postgres  |   6 |   99.00 | 139.94 |   0.20 |      0.00
 wangxin   |   4 |   99.00 | 132.22 |   0.17 |      0.00
 wangxin1  |   4 |   99.00 | 133.25 |   0.19 |      0.00
 template1 |   0 |       0 |   0.00 |   0.00 |      0.00
 template0 |   0 |       0 |   0.00 |   0.00 |      0.00
(5 rows)


Database tuples information:
 database |  tup  | tup_pct_ins | tup_pct_upd | tup_pct_del 
----------+-------+-------------+-------------+-------------
 postgres | 40076 |           0 |           0 |           0
(1 row)


Top 20 tables ordered by table size changes
          table          | table_growth | index_growth 
-------------------------+--------------+--------------
 pgstatspack_settings    |        24576 |         8192
 pgstatspack_tables      |        16384 |         8192
 pgstatspack_indexes     |        16384 |         8192
 pgstatspack_statements  |         8192 |            0
 pg_type                 |            0 |            0
 pg_policy               |            0 |            0
 pg_opclass              |            0 |            0
 pg_ts_config            |            0 |            0
 pg_toast_13122          |            0 |            0
 pg_toast_13137          |            0 |            0
 pg_db_role_setting      |            0 |            0
 pg_foreign_data_wrapper |            0 |            0
 pg_largeobject          |            0 |            0
 pg_toast_42602          |            0 |            0
 pg_constraint           |            0 |            0
 pg_ts_parser            |            0 |            0
 pg_shdescription        |            0 |            0
 pg_toast_13127          |            0 |            0
 pg_opfamily             |            0 |            0
 pg_publication          |            0 |            0
(20 rows)


Top 20 tables ordered by high table to index read ratio
       table       | system_read_pct | table_read_pct | index_read_pct 
-------------------+-----------------+----------------+----------------
 pg_proc           |              45 |             98 |              1
 pg_class          |              37 |             85 |             14
 pg_index          |               5 |             90 |              9
 pg_attribute      |               3 |              0 |            100
 pg_opclass        |               3 |              0 |            100
 pg_am             |               0 |            100 |              0
 pg_authid         |               0 |             89 |             10
 pg_namespace      |               0 |             85 |             14
 pg_database       |               0 |             75 |             24
 pgstatspack_names |               0 |             43 |             56
 pg_cast           |               0 |              0 |            100
 pg_statistic      |               0 |              0 |            100
 pg_language       |               0 |              0 |            100
 pg_rewrite        |               0 |              0 |            100
 pg_attrdef        |               0 |              0 |            100
 pg_sequence       |               0 |              0 |            100
 pg_aggregate      |               0 |              0 |            100
 pg_type           |               0 |              0 |            100
 pg_amop           |               0 |              0 |            100
 pg_toast_2618     |               0 |              0 |            100
(20 rows)


Top 20 tables ordered by inserts
          table          | table_inserts 
-------------------------+---------------
 pgstatspack_settings    |           299
 pgstatspack_indexes     |           151
 pgstatspack_tables      |           106
 pgstatspack_statements  |            53
 pgstatspack_space_usage |             5
 pgstatspack_database    |             5
 pgstatspack_activity    |             2
 pgstatspack_sequences   |             2
 pgstatspack_functions   |             2
 pgstatspack_snap        |             1
 pgstatspack_bgwriter    |             1
 pg_largeobject          |             0
 pg_policy               |             0
 pg_toast_42602          |             0
 pg_foreign_data_wrapper |             0
 pg_db_role_setting      |             0
 pg_type                 |             0
 pg_opclass              |             0
 pg_toast_13137          |             0
 pg_ts_config            |             0
(20 rows)


Top 20 tables ordered by updates
          table          | table_updates 
-------------------------+---------------
 pg_foreign_server       |             0
 pg_opclass              |             0
 pg_aggregate            |             0
 pg_toast_13122          |             0
 pg_type                 |             0
 pg_policy               |             0
 pg_publication          |             0
 pg_ts_parser            |             0
 pgstatspack_statements  |             0
 pg_toast_13137          |             0
 pg_db_role_setting      |             0
 pg_foreign_data_wrapper |             0
 pg_largeobject          |             0
 pg_toast_42602          |             0
 pg_opfamily             |             0
 pg_shdescription        |             0
 pg_constraint           |             0
 pg_toast_13127          |             0
 pg_ts_config            |             0
 pg_foreign_table        |             0
(20 rows)


Top 20 tables ordered by deletes
          table          | table_deletes 
-------------------------+---------------
 pg_foreign_server       |             0
 pg_opclass              |             0
 pg_aggregate            |             0
 pg_toast_13122          |             0
 pg_type                 |             0
 pg_policy               |             0
 pg_publication          |             0
 pg_ts_parser            |             0
 pgstatspack_statements  |             0
 pg_toast_13137          |             0
 pg_db_role_setting      |             0
 pg_foreign_data_wrapper |             0
 pg_largeobject          |             0
 pg_toast_42602          |             0
 pg_opfamily             |             0
 pg_shdescription        |             0
 pg_constraint           |             0
 pg_toast_13127          |             0
 pg_ts_config            |             0
 pg_foreign_table        |             0
(20 rows)


Tables ordered by percentage of tuples scanned
       table       | rows_read_pct | tab_hitrate | idx_hitrate | tab_read | tab_hit | idx_read | idx_hit 
-------------------+---------------+-------------+-------------+----------+---------+----------+---------
 pg_proc           |            45 |          99 |          99 |        0 |     690 |        0 |     422
 pg_class          |            37 |          99 |          99 |        0 |    2670 |        0 |    4650
 pg_index          |             5 |          99 |          99 |        0 |     268 |        0 |     222
 pg_attribute      |             3 |          99 |          99 |        0 |     670 |        0 |    1326
 pg_opclass        |             3 |          99 |          99 |        0 |     596 |        0 |     100
 pg_namespace      |             0 |          95 |          95 |        0 |      20 |        0 |      20
 pg_toast_2619     |             0 |          50 |          66 |        0 |       1 |        0 |       2
 pg_tablespace     |             0 |          93 |          95 |        0 |      14 |        0 |      22
 pg_database       |             0 |          99 |          99 |        0 |     130 |        0 |     106
 pg_operator       |             0 |          99 |          99 |        0 |     162 |        0 |     150
 pg_amproc         |             0 |          98 |          99 |        0 |      54 |        0 |     122
 pg_am             |             0 |          85 |           0 |        0 |       6 |        0 |       0
 pg_toast_1255     |             0 |          66 |          75 |        0 |       2 |        0 |       3
 pg_cast           |             0 |          98 |          99 |        0 |      60 |        0 |     358
 pg_statistic      |             0 |          92 |          97 |        0 |      13 |        0 |      40
 pg_language       |             0 |          66 |          80 |        0 |       2 |        0 |       4
 pgstatspack_names |             0 |          98 |          98 |        0 |      50 |        0 |      50
 pg_rewrite        |             0 |          96 |          96 |        0 |      28 |        0 |      28
 pg_authid         |             0 |          96 |          96 |        0 |      30 |        0 |      32
 pg_attrdef        |             0 |          66 |          80 |        0 |       2 |        0 |       4
 pg_sequence       |             0 |          50 |          66 |        0 |       1 |        0 |       2
 pg_aggregate      |             0 |          75 |          80 |        0 |       3 |        0 |       4
 pg_type           |             0 |          99 |          99 |        0 |     136 |        0 |     302
 pg_amop           |             0 |          99 |          99 |        0 |     261 |        0 |     360
 pg_toast_2618     |             0 |          91 |          90 |        0 |      11 |        0 |       9
(25 rows)


Indexes ordered by scans
                     index                     |          table          | scans | tup_read | tup_fetch | idx_blks_read | idx_blks_hit 
-----------------------------------------------+-------------------------+-------+----------+-----------+---------------+--------------
 pg_class_oid_index                            | pg_class                |   726 |      726 |       726 |             0 |         1459
 pg_attribute_relid_attnum_index               | pg_attribute            |   328 |      790 |       790 |             0 |          663
 pg_cast_source_target_index                   | pg_cast                 |   177 |       30 |        30 |             0 |          179
 pg_proc_oid_index                             | pg_proc                 |    95 |       95 |        95 |             0 |          192
 pg_index_indexrelid_index                     | pg_index                |    85 |       85 |        85 |             0 |           88
 pg_type_oid_index                             | pg_type                 |    65 |       64 |        64 |             0 |          132
 pg_class_relname_nsp_index                    | pg_class                |    44 |       30 |        30 |             0 |           90
 pg_amop_fam_strat_index                       | pg_amop                 |    38 |       38 |        38 |             0 |           78
 pg_amproc_fam_proc_index                      | pg_amproc               |    29 |       40 |        40 |             0 |           61
 pg_opclass_oid_index                          | pg_opclass              |    29 |       29 |        29 |             0 |           32
 pg_db_role_setting_databaseid_rol_index       | pg_db_role_setting      |    28 |        0 |         0 |             0 |           28
 pg_database_datname_index                     | pg_database             |    26 |       26 |        26 |             0 |           33
 idx_pgstatspack_names_name                    | pgstatspack_names       |    23 |       23 |        23 |             0 |           24
 pg_operator_oid_index                         | pg_operator             |    21 |       21 |        21 |             0 |           44
 pg_index_indrelid_index                       | pg_index                |    21 |       30 |        30 |             0 |           23
 pg_amop_opr_fam_index                         | pg_amop                 |    20 |       51 |        51 |             0 |           42
 pg_statistic_relid_att_inh_index              | pg_statistic            |    19 |       13 |        13 |             0 |           40
 pg_opclass_am_name_nsp_index                  | pg_opclass              |    17 |      717 |       717 |             0 |           18
 pg_operator_oprname_l_r_n_index               | pg_operator             |    14 |       84 |        84 |             0 |           31
 pg_rewrite_rel_rulename_index                 | pg_rewrite              |    13 |       15 |        15 |             0 |           14
 pg_database_oid_index                         | pg_database             |    13 |       13 |        13 |             0 |           20
 pg_proc_proname_args_nsp_index                | pg_proc                 |     9 |       26 |        26 |             0 |           19
 pg_type_typname_nsp_index                     | pg_type                 |     9 |        4 |         4 |             0 |           19
 pg_statistic_ext_relid_index                  | pg_statistic_ext        |     8 |        0 |         0 |             0 |            8
 pg_toast_2618_index                           | pg_toast_2618           |     8 |       24 |        24 |             0 |            9
 pg_tablespace_oid_index                       | pg_tablespace           |     7 |        7 |         7 |             0 |           11
 pg_namespace_nspname_index                    | pg_namespace            |     7 |        5 |         5 |             0 |            9
 pg_authid_oid_index                           | pg_authid               |     4 |        4 |         4 |             0 |            8
 pg_authid_rolname_index                       | pg_authid               |     4 |        4 |         4 |             0 |            8
 pg_aggregate_fnoid_index                      | pg_aggregate            |     3 |        3 |         3 |             0 |            4
 pg_constraint_conrelid_contypid_conname_index | pg_constraint           |     3 |        0 |         0 |             0 |            4
 pg_toast_1255_index                           | pg_toast_1255           |     2 |        4 |         4 |             0 |            3
 pg_attrdef_adrelid_adnum_index                | pg_attrdef              |     1 |        1 |         1 |             0 |            2
 pg_toast_2619_index                           | pg_toast_2619           |     1 |        1 |         1 |             0 |            2
 pg_language_oid_index                         | pg_language             |     1 |        1 |         1 |             0 |            2
 pg_sequence_seqrelid_index                    | pg_sequence             |     1 |        1 |         1 |             0 |            2
 pgstatspack_indexes_pk                        | pgstatspack_indexes     |     0 |        0 |         0 |             1 |          304
 pgstatspack_sequences_pk                      | pgstatspack_sequences   |     0 |        0 |         0 |             0 |            3
 pgstatspack_settings_pk                       | pgstatspack_settings    |     0 |        0 |         0 |             1 |          600
 pgstatspack_statements_pk                     | pgstatspack_statements  |     0 |        0 |         0 |             0 |          107
 pgstatspack_functions_pk                      | pgstatspack_functions   |     0 |        0 |         0 |             1 |            2
 pgstatspack_bgwriter_pk                       | pgstatspack_bgwriter    |     0 |        0 |         0 |             0 |            2
 pgstatspack_activity_pkey                     | pgstatspack_activity    |     0 |        0 |         0 |             0 |            3
 pgstatspack_space_usage_pk                    | pgstatspack_space_usage |     0 |        0 |         0 |             0 |            6
 pgstatspack_names_pkey                        | pgstatspack_names       |     0 |        0 |         0 |             0 |            1
 pg_class_tblspc_relfilenode_index             | pg_class                |     0 |        0 |         0 |             0 |            1
 pg_namespace_oid_index                        | pg_namespace            |     0 |        0 |         0 |             0 |            1
 pgstatspack_database_pk                       | pgstatspack_database    |     0 |        0 |         0 |             0 |            6
 pgstatspack_tables_pk                         | pgstatspack_tables      |     0 |        0 |         0 |             1 |          214
(49 rows)


Sequences ordered by blks_read
   sequence    | blks_read | blks_hit 
---------------+-----------+----------
 pgstatspackid |         0 |        1
(1 row)


Top 20 SQL statements ordered by total_time
 calls | total_time | rows |   user   |                           query                           
-------+------------+------+----------+-----------------------------------------------------------
     6 |       0.63 |    6 | postgres | select cast(substring(version(), $1) as int)
     6 |       0.63 |    6 | postgres | select cast(substring(version(), $1) as int)
     6 |       0.63 |    6 | postgres | select cast(substring(version(), $1) as int)
     6 |       0.63 |    6 | postgres | select cast(substring(version(), $1) as int)
     6 |       0.63 |    6 | postgres | select cast(substring(version(), $1) as int)
     6 |       0.63 |    6 | postgres | select cast(substring(version(), $1) as int)
     6 |       0.63 |    6 | postgres | select cast(substring(version(), $1) as int)
     6 |       0.63 |    6 | postgres | select cast(substring(version(), $1) as int)
     6 |       0.63 |    6 | postgres | select cast(substring(version(), $1) as int)
     3 |       0.17 |    3 | postgres | SELECT nextval($1)
     3 |       0.17 |    3 | postgres | SELECT nextval($1)
     3 |       0.17 |    3 | postgres | SELECT nextval($1)
     3 |       0.17 |    3 | postgres | SELECT nextval($1)
     3 |       0.17 |    3 | postgres | SELECT nextval($1)
     3 |       0.17 |    3 | postgres | SELECT nextval($1)
     3 |       0.17 |    3 | postgres | SELECT nextval($1)
     3 |       0.17 |    3 | postgres | SELECT nextval($1)
     3 |       0.17 |    3 | postgres | SELECT nextval($1)
     1 |       0.02 |    3 | postgres | select datname from pg_database where datname not like $1
     3 |       0.01 |    3 | postgres | SELECT current_timestamp
(20 rows)


Top 20 user functions ordered by total_time
 funcid |       function_name       | calls | total_time | self_time 
--------+---------------------------+-------+------------+-----------
  50769 | public.pgstatspack_snap   |     1 |     49.000 |    49.000
  24587 | public.pg_stat_statements |     1 |      0.000 |     0.000
(2 rows)


background writer stats
 checkpoints_timed | checkpoints_req | buffers_checkpoint | buffers_clean | maxwritten_clean | buffers_backend | buffers_alloc 
-------------------+-----------------+--------------------+---------------+------------------+-----------------+---------------
                 0 |               0 |                  0 |             0 |                0 |               0 |            33
(1 row)


background writer relative stats
 checkpoints_timed | minutes_between_checkpoint | buffers_checkpoint | buffers_clean | buffers_backend | total_writes | avg_checkpoint_write 
-------------------+----------------------------+--------------------+---------------+-----------------+--------------+----------------------
                   |                            |                    |               |                 | 0.000 MB/s   | 
(1 row)


activity stats
 current_sessions | current_active_sessions | old_sessions | old_active_sessions | delta_sessions | delta_active_sessions 
------------------+-------------------------+--------------+---------------------+----------------+-----------------------
                2 |                       1 |            1 |                   1 |              1 |                     0
(1 row)


Parameters
                  name                  |         start_setting          |          stop_setting          |        source        
----------------------------------------+--------------------------------+--------------------------------+----------------------
 allow_system_table_mods                | off                            | off                            | default
 application_name                       | psql                           | psql                           | client
 archive_command                        | (disabled)                     | (disabled)                     | default
 archive_mode                           | off                            | off                            | default
 archive_timeout                        | 0                              | 0                              | default
 array_nulls                            | on                             | on                             | default
 authentication_timeout                 | 60                             | 60                             | default
 autovacuum                             | on                             | on                             | default
 autovacuum_analyze_scale_factor        | 0.1                            | 0.1                            | default
 autovacuum_analyze_threshold           | 50                             | 50                             | default
 autovacuum_freeze_max_age              | 200000000                      | 200000000                      | default
 autovacuum_max_workers                 | 3                              | 3                              | default
 autovacuum_multixact_freeze_max_age    | 400000000                      | 400000000                      | default
 autovacuum_naptime                     | 60                             | 60                             | default
 autovacuum_vacuum_cost_delay           | 20                             | 20                             | default
 autovacuum_vacuum_cost_limit           | -1                             | -1                             | default
 autovacuum_vacuum_scale_factor         | 0.2                            | 0.2                            | default
 autovacuum_vacuum_threshold            | 50                             | 50                             | default
 autovacuum_work_mem                    | -1                             | -1                             | default
 backend_flush_after                    | 0                              | 0                              | default
 backslash_quote                        | safe_encoding                  | safe_encoding                  | default
 bgwriter_delay                         | 200                            | 200                            | default
 bgwriter_flush_after                   | 64                             | 64                             | default
 bgwriter_lru_maxpages                  | 100                            | 100                            | default
 bgwriter_lru_multiplier                | 2                              | 2                              | default
 block_size                             | 8192                           | 8192                           | default
 bonjour                                | off                            | off                            | default
 bonjour_name                           |                                |                                | default
 bytea_output                           | hex                            | hex                            | default
 check_function_bodies                  | on                             | on                             | default
 checkpoint_completion_target           | 0.5                            | 0.5                            | default
 checkpoint_flush_after                 | 32                             | 32                             | default
 checkpoint_timeout                     | 300                            | 300                            | default
 checkpoint_warning                     | 30                             | 30                             | default
 client_encoding                        | UTF8                           | UTF8                           | default
 client_min_messages                    | notice                         | notice                         | default
 cluster_name                           |                                |                                | default
 commit_delay                           | 0                              | 0                              | default
 commit_siblings                        | 5                              | 5                              | default
 config_file                            | /PgData/postgresql.conf        | /PgData/postgresql.conf        | override
 constraint_exclusion                   | partition                      | partition                      | default
 cpu_index_tuple_cost                   | 0.005                          | 0.005                          | default
 cpu_operator_cost                      | 0.0025                         | 0.0025                         | default
 cpu_tuple_cost                         | 0.01                           | 0.01                           | default
 cursor_tuple_fraction                  | 0.1                            | 0.1                            | default
 data_checksums                         | off                            | off                            | override
 data_directory                         | /PgData                        | /PgData                        | override
 data_directory_mode                    | 0700                           | 0700                           | default
 data_sync_retry                        | off                            | off                            | default
 DateStyle                              | ISO, MDY                       | ISO, MDY                       | configuration file
 db_user_namespace                      | off                            | off                            | default
 deadlock_timeout                       | 1000                           | 1000                           | default
 debug_assertions                       | off                            | off                            | default
 debug_pretty_print                     | on                             | on                             | default
 debug_print_parse                      | off                            | off                            | default
 debug_print_plan                       | off                            | off                            | default
 debug_print_rewritten                  | off                            | off                            | default
 default_statistics_target              | 100                            | 100                            | default
 default_tablespace                     |                                |                                | default
 default_text_search_config             | pg_catalog.english             | pg_catalog.english             | configuration file
 default_transaction_deferrable         | off                            | off                            | default
 default_transaction_isolation          | read committed                 | read committed                 | default
 default_transaction_read_only          | off                            | off                            | default
 default_with_oids                      | off                            | off                            | default
 dynamic_library_path                   | $libdir                        | $libdir                        | default
 dynamic_shared_memory_type             | posix                          | posix                          | configuration file
 effective_cache_size                   | 524288                         | 524288                         | default
 effective_io_concurrency               | 1                              | 1                              | default
 enable_bitmapscan                      | on                             | on                             | default
 enable_gathermerge                     | on                             | on                             | default
 enable_hashagg                         | on                             | on                             | default
 enable_hashjoin                        | on                             | on                             | default
 enable_indexonlyscan                   | on                             | on                             | default
 enable_indexscan                       | on                             | on                             | default
 enable_material                        | on                             | on                             | default
 enable_mergejoin                       | on                             | on                             | default
 enable_nestloop                        | on                             | on                             | default
 enable_parallel_append                 | on                             | on                             | default
 enable_parallel_hash                   | on                             | on                             | default
 enable_partition_pruning               | on                             | on                             | default
 enable_partitionwise_aggregate         | off                            | off                            | default
 enable_partitionwise_join              | off                            | off                            | default
 enable_seqscan                         | on                             | on                             | default
 enable_sort                            | on                             | on                             | default
 enable_tidscan                         | on                             | on                             | default
 escape_string_warning                  | on                             | on                             | default
 event_source                           | PostgreSQL                     | PostgreSQL                     | default
 exit_on_error                          | off                            | off                            | default
 external_pid_file                      |                                |                                | default
 extra_float_digits                     | 0                              | 0                              | default
 force_parallel_mode                    | off                            | off                            | default
 from_collapse_limit                    | 8                              | 8                              | default
 fsync                                  | on                             | on                             | default
 full_page_writes                       | on                             | on                             | default
 geqo                                   | on                             | on                             | default
 geqo_effort                            | 5                              | 5                              | default
 geqo_generations                       | 0                              | 0                              | default
 geqo_pool_size                         | 0                              | 0                              | default
 geqo_seed                              | 0                              | 0                              | default
 geqo_selection_bias                    | 2                              | 2                              | default
 geqo_threshold                         | 12                             | 12                             | default
 gin_fuzzy_search_limit                 | 0                              | 0                              | default
 gin_pending_list_limit                 | 4096                           | 4096                           | default
 hba_file                               | /PgData/pg_hba.conf            | /PgData/pg_hba.conf            | override
 hot_standby                            | on                             | on                             | default
 hot_standby_feedback                   | off                            | off                            | default
 huge_pages                             | try                            | try                            | default
 ident_file                             | /PgData/pg_ident.conf          | /PgData/pg_ident.conf          | override
 idle_in_transaction_session_timeout    | 0                              | 0                              | default
 ignore_checksum_failure                | off                            | off                            | default
 ignore_system_indexes                  | off                            | off                            | default
 integer_datetimes                      | on                             | on                             | default
 IntervalStyle                          | postgres                       | postgres                       | default
 jit                                    | off                            | off                            | default
 jit_above_cost                         | 100000                         | 100000                         | default
 jit_debugging_support                  | off                            | off                            | default
 jit_dump_bitcode                       | off                            | off                            | default
 jit_expressions                        | on                             | on                             | default
 jit_inline_above_cost                  | 500000                         | 500000                         | default
 jit_optimize_above_cost                | 500000                         | 500000                         | default
 jit_profiling_support                  | off                            | off                            | default
 jit_provider                           | llvmjit                        | llvmjit                        | default
 jit_tuple_deforming                    | on                             | on                             | default
 join_collapse_limit                    | 8                              | 8                              | default
 krb_caseins_users                      | off                            | off                            | default
 krb_server_keyfile                     |                                |                                | default
 lc_collate                             | en_US.UTF-8                    | en_US.UTF-8                    | override
 lc_ctype                               | en_US.UTF-8                    | en_US.UTF-8                    | override
 lc_messages                            | en_US.UTF-8                    | en_US.UTF-8                    | configuration file
 lc_monetary                            | en_US.UTF-8                    | en_US.UTF-8                    | configuration file
 lc_numeric                             | en_US.UTF-8                    | en_US.UTF-8                    | configuration file
 lc_time                                | en_US.UTF-8                    | en_US.UTF-8                    | configuration file
 listen_addresses                       | *                              | *                              | configuration file
 local_preload_libraries                |                                |                                | default
 lock_timeout                           | 0                              | 0                              | default
 lo_compat_privileges                   | off                            | off                            | default
 log_autovacuum_min_duration            | -1                             | -1                             | default
 log_checkpoints                        | off                            | off                            | default
 log_connections                        | off                            | off                            | default
 log_destination                        | csvlog                         | csvlog                         | configuration file
 log_directory                          | /PgData/pg_log                 | /PgData/pg_log                 | configuration file
 log_disconnections                     | off                            | off                            | default
 log_duration                           | off                            | off                            | default
 log_error_verbosity                    | default                        | default                        | default
 log_executor_stats                     | off                            | off                            | default
 log_file_mode                          | 0600                           | 0600                           | default
 log_filename                           | postgresql-%Y-%m-%d_%H%M%S.log | postgresql-%Y-%m-%d_%H%M%S.log | configuration file
 logging_collector                      | on                             | on                             | configuration file
 log_hostname                           | off                            | off                            | default
 log_line_prefix                        | %t                             | %t                             | configuration file
 log_lock_waits                         | off                            | off                            | default
 log_min_duration_statement             | -1                             | -1                             | default
 log_min_error_statement                | error                          | error                          | default
 log_min_messages                       | warning                        | warning                        | default
 log_parser_stats                       | off                            | off                            | default
 log_planner_stats                      | off                            | off                            | default
 log_replication_commands               | off                            | off                            | default
 log_rotation_age                       | 1440                           | 1440                           | configuration file
 log_rotation_size                      | 10240                          | 10240                          | default
 log_statement                          | none                           | none                           | default
 log_statement_stats                    | off                            | off                            | default
 log_temp_files                         | -1                             | -1                             | default
 log_timezone                           | PRC                            | PRC                            | configuration file
 log_truncate_on_rotation               | off                            | off                            | default
 maintenance_work_mem                   | 65536                          | 65536                          | default
 max_connections                        | 100                            | 100                            | configuration file
 max_files_per_process                  | 1000                           | 1000                           | default
 max_function_args                      | 100                            | 100                            | default
 max_identifier_length                  | 63                             | 63                             | default
 max_index_keys                         | 32                             | 32                             | default
 max_locks_per_transaction              | 64                             | 64                             | default
 max_logical_replication_workers        | 4                              | 4                              | default
 max_parallel_maintenance_workers       | 2                              | 2                              | default
 max_parallel_workers                   | 8                              | 8                              | default
 max_parallel_workers_per_gather        | 2                              | 2                              | default
 max_pred_locks_per_page                | 2                              | 2                              | default
 max_pred_locks_per_relation            | -2                             | -2                             | default
 max_pred_locks_per_transaction         | 64                             | 64                             | default
 max_prepared_transactions              | 0                              | 0                              | default
 max_replication_slots                  | 10                             | 10                             | default
 max_stack_depth                        | 2048                           | 2048                           | environment variable
 max_standby_archive_delay              | 30000                          | 30000                          | default
 max_standby_streaming_delay            | 30000                          | 30000                          | default
 max_sync_workers_per_subscription      | 2                              | 2                              | default
 max_wal_senders                        | 3                              | 3                              | configuration file
 max_wal_size                           | 1024                           | 1024                           | configuration file
 max_worker_processes                   | 8                              | 8                              | default
 min_parallel_index_scan_size           | 64                             | 64                             | default
 min_parallel_table_scan_size           | 1024                           | 1024                           | default
 min_wal_size                           | 80                             | 80                             | configuration file
 old_snapshot_threshold                 | -1                             | -1                             | default
 operator_precedence_warning            | off                            | off                            | default
 parallel_leader_participation          | on                             | on                             | default
 parallel_setup_cost                    | 1000                           | 1000                           | default
 parallel_tuple_cost                    | 0.1                            | 0.1                            | default
 password_encryption                    | md5                            | md5                            | default
 pg_stat_statements.max                 | 10000                          | 10000                          | configuration file
 pg_stat_statements.save                | on                             | on                             | configuration file
 pg_stat_statements.track               | all                            | all                            | configuration file
 pg_stat_statements.track_utility       | on                             | on                             | configuration file
 plpgsql.check_asserts                  | on                             | on                             | default
 plpgsql.extra_errors                   | none                           | none                           | default
 plpgsql.extra_warnings                 | none                           | none                           | default
 plpgsql.print_strict_params            | off                            | off                            | default
 plpgsql.variable_conflict              | error                          | error                          | default
 port                                   | 15432                          | 15432                          | configuration file
 post_auth_delay                        | 0                              | 0                              | default
 pre_auth_delay                         | 0                              | 0                              | default
 quote_all_identifiers                  | off                            | off                            | default
 random_page_cost                       | 4                              | 4                              | default
 restart_after_crash                    | on                             | on                             | default
 row_security                           | on                             | on                             | default
 search_path                            | "$user", public                | "$user", public                | default
 segment_size                           | 131072                         | 131072                         | default
 seq_page_cost                          | 1                              | 1                              | default
 server_encoding                        | UTF8                           | UTF8                           | override
 server_version                         | 11.4                           | 11.4                           | default
 server_version_num                     | 110004                         | 110004                         | default
 session_preload_libraries              |                                |                                | default
 session_replication_role               | origin                         | origin                         | default
 shared_buffers                         | 32768                          | 32768                          | configuration file
 shared_preload_libraries               | pg_stat_statements             | pg_stat_statements             | configuration file
 ssl                                    | off                            | off                            | default
 ssl_ca_file                            |                                |                                | default
 ssl_cert_file                          | server.crt                     | server.crt                     | default
 ssl_ciphers                            | none                           | none                           | default
 ssl_crl_file                           |                                |                                | default
 ssl_dh_params_file                     |                                |                                | default
 ssl_ecdh_curve                         | none                           | none                           | default
 ssl_key_file                           | server.key                     | server.key                     | default
 ssl_passphrase_command                 |                                |                                | default
 ssl_passphrase_command_supports_reload | off                            | off                            | default
 ssl_prefer_server_ciphers              | on                             | on                             | default
 standard_conforming_strings            | on                             | on                             | default
 statement_timeout                      | 0                              | 0                              | default
 stats_temp_directory                   | pg_stat_tmp                    | pg_stat_tmp                    | default
 superuser_reserved_connections         | 5                              | 5                              | configuration file
 synchronize_seqscans                   | on                             | on                             | default
 synchronous_commit                     | on                             | on                             | default
 synchronous_standby_names              |                                |                                | default
 syslog_facility                        | local0                         | local0                         | default
 syslog_ident                           | postgres                       | postgres                       | default
 syslog_sequence_numbers                | on                             | on                             | default
 syslog_split_messages                  | on                             | on                             | default
 tcp_keepalives_count                   | 0                              | 0                              | configuration file
 tcp_keepalives_idle                    | 0                              | 0                              | configuration file
 tcp_keepalives_interval                | 0                              | 0                              | configuration file
 temp_buffers                           | 1024                           | 1024                           | default
 temp_file_limit                        | -1                             | -1                             | default
 temp_tablespaces                       |                                |                                | default
 TimeZone                               | PRC                            | PRC                            | configuration file
 timezone_abbreviations                 | Default                        | Default                        | default
 trace_notify                           | off                            | off                            | default
 trace_recovery_messages                | log                            | log                            | default
 trace_sort                             | off                            | off                            | default
 track_activities                       | on                             | on                             | default
 track_activity_query_size              | 1024                           | 1024                           | default
 track_commit_timestamp                 | off                            | off                            | default
 track_counts                           | on                             | on                             | default
 track_functions                        | all                            | all                            | configuration file
 track_io_timing                        | on                             | on                             | configuration file
 transaction_deferrable                 | off                            | off                            | override
 transaction_isolation                  | read committed                 | read committed                 | override
 transaction_read_only                  | off                            | off                            | override
 transform_null_equals                  | off                            | off                            | default
 unix_socket_directories                | /tmp                           | /tmp                           | default
 unix_socket_group                      |                                |                                | default
 unix_socket_permissions                | 0700                           | 0700                           | configuration file
 update_process_title                   | on                             | on                             | default
 vacuum_cleanup_index_scale_factor      | 0.1                            | 0.1                            | default
 vacuum_cost_delay                      | 0                              | 0                              | default
 vacuum_cost_limit                      | 200                            | 200                            | default
 vacuum_cost_page_dirty                 | 20                             | 20                             | default
 vacuum_cost_page_hit                   | 1                              | 1                              | default
 vacuum_cost_page_miss                  | 10                             | 10                             | default
 vacuum_defer_cleanup_age               | 0                              | 0                              | default
 vacuum_freeze_min_age                  | 50000000                       | 50000000                       | default
 vacuum_freeze_table_age                | 150000000                      | 150000000                      | default
 vacuum_multixact_freeze_min_age        | 5000000                        | 5000000                        | default
 vacuum_multixact_freeze_table_age      | 150000000                      | 150000000                      | default
 wal_block_size                         | 8192                           | 8192                           | default
 wal_buffers                            | 1024                           | 1024                           | override
 wal_compression                        | off                            | off                            | default
 wal_consistency_checking               |                                |                                | default
 wal_keep_segments                      | 0                              | 0                              | default
 wal_level                              | replica                        | replica                        | default
 wal_log_hints                          | off                            | off                            | default
 wal_receiver_status_interval           | 10                             | 10                             | default
 wal_receiver_timeout                   | 60000                          | 60000                          | default
 wal_retrieve_retry_interval            | 5000                           | 5000                           | default
 wal_segment_size                       | 16777216                       | 16777216                       | override
 wal_sender_timeout                     | 60000                          | 60000                          | default
 wal_sync_method                        | fdatasync                      | fdatasync                      | default
 wal_writer_delay                       | 200                            | 200                            | default
 wal_writer_flush_after                 | 128                            | 128                            | default
 work_mem                               | 4096                           | 4096                           | default
 xmlbinary                              | base64                         | base64                         | default
 xmloption                              | content                        | content                        | default
 zero_damaged_pages                     | off                            | off                            | default
(299 rows)


This report is saved as /tmp/pgstatreport_postgres_75_76.txt

/home/soft/pgstatspack-2.3.3.1/bin

Guess you like

Origin blog.csdn.net/wx370092877/article/details/109532532