postgresql性能分析工具-pgstatpack-2.3.3.1

一、前言

数据库日常运行过程中的性能监控和状态判别,是数据库日常的运行维护工作中重要部分之一。也是我们平时对数据库进行性能问题排查、系统优化的一个重要凭证。
Oracle数据库,通过AWR报告、ASH报告对数据库的某个时间段的运行状态及性能进行信息的收集和统计,然后判断这段时间的数据库运行性能瓶颈。究其根本,Oracle会在每隔1s(默认)收集当前数据库的非空闲等待事件信息、会话信息等,并存放于相关的ASH视图中。AWR报告则是每小时(默认、可设置),对数据库的运行情况保存一个快照信息,在进行性能分析的时候,则可以通过awr相关视图或者awr报告获取到在一段事件内,数据库的运行情况。在9i前,AWR被称为statpack。在9i后,则被正式命名为awr。
但是对于postgreSQL来讲,目前并没有在其中集成类似于AWR的功能。因此,对于PostgreSQL,我们只能采取选用其他的工具包来实现该功能,从而帮助我们更好的监控、获取一个时间段内postgreSQL数据库的性能。

二、工具下载地址

pgstatpack,则是一个对于PostgreSQL非常好的性能分析工具,其部署简单轻便,使用方便。可以通过启用定时任务的方式,对PostgreSQL数据库保存快照,帮助用户进行比对分析。
目前,我们可以下载到的版本是:pgstatpack-2.3.3
下载地址:
http://www.xenialab.it/meo/web/pub/pgstatspack-2.3.3.zip
但是在使用测试过程中,发现该版本部分内容并不是特别完善,比如表、sql、索引等快照信息并没有收集。
所以,在使用的过程中,为了更贴近实际使用情况,我对该版本的工具包进行了进一步的优化,完善了报告内容、表收集内容、视图收集内容,以及生成快照、删除快照、生成报告的脚本。
新版本下载地址:
https://pan.baidu.com/s/1HhFkd0kL8G7PqVYW5YFCLg
验证码:alda
(大家可以直接下载下来使用,并根据实际情况进行修改)。

三、工具使用

1)简介

接下来,我对该工具的安装、使用方法等做一个简单的介绍:
在该工具中,核心文件主要是以下几个:
1.文件夹bin中,存放着三个.sh脚本
snapshot.sh
delete_snapshot.sh
pgstatpack_report.sh
其中,
snapshot.sh脚本,是通过linux主机的crontab进行设置,可以定时执行该脚本,为postgresql收集快照,用于记录快照时刻的数据库运行情况;
delete_snapshot.sh脚本,也是通过Linux主机的crontab进行设置,可以定时执行该脚本。为postgresql数据库删除历史快照;
pgstatpack_report.sh脚本,可以直接执行,获取相关快照中的信息,生成两个快照期间的数据库运行情况,类似于oracle的AWR报告。
2.sql文件夹文件夹sql中主要存放了创建各个快照的表信息、视图信息以及创建快照的函数、删除快照的函数、获取工具安装基础信息等。
主要文件如下:
pgstatspack_create_snap.sql,用于创建快照生成函数
pgstatspack_create_tables.sql,用于创建快照相关表、视图,做安装用
pgstatspack_delete_old_stats.sql,用于创建删除快照函数
pgstatspack_remove_tables.sql,用于删除快照表,做卸载用
3.install_pgstats.sh
该脚本主要用于安装工具
4.pgstatspack_stat_explanation.txt
该文本是对各个参数进行说明

2)安装

1.解压包

unzip pgstatspack-2.3.3.1.zip

2.使用具有Postgres数据库superadmin权限的用户执行脚本安装脚本:

sh install_pgstats.sh

输入postgresql端口即可

3)使用

为了方便使用,最开始我们需要把pg_stat_statements插件部署上

指定定时任务,收集快照:
crontab -e

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

生成报告:

sh pgstatpack_report.sh

输入数据库名字和数据库端口即可生成报告。

四、示例

安装成功后,可以看到的每个数据库中会存在以下表、视图、序列

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)

生成报告示例:

[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

猜你喜欢

转载自blog.csdn.net/wx370092877/article/details/109532532